Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 45025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:44:39+00:00 2026-05-10T15:44:39+00:00

I’ve got a custom handler applied to a class (using the Policy Injection Application

  • 0

I’ve got a custom handler applied to a class (using the Policy Injection Application Block in entlib 4) and I would like to know whether the input method is a property when Invoke is called. Following is what my handler looks like.

[ConfigurationElementType(typeof(MyCustomHandlerData))] public class MyCustomHandler : ICallHandler {     public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)     {         if (input.MethodBase.IsPublic && (input.MethodBase.Name.Contains('get_') || input.MethodBase.Name.Contains('set_')))         {             Console.WriteLine('MyCustomHandler Invoke called with input of {0}', input.MethodBase.Name);         }         return getNext().Invoke(input, getNext);     }      public int Order { get; set; } } 

As you can see from my code sample, the best way I’ve thought of so far is by parsing the method name. Isn’t there a better way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:44:40+00:00Added an answer on May 10, 2026 at 3:44 pm

    You can also check IsSpecialName is true. this will be true in a property (amongst other things)

    At the il level the methods are exposed as follows (using Environment.ExitCode as example):

    .method public hidebysig specialname static int32 get_ExitCode() cil managed .method public hidebysig specialname static void set_ExitCode(int32 'value') cil managed 

    If you wanted to get fancy you could verify after extracting the name that said property exists but to be honest

    if (m.IsSpecialName && (m.Attributes & MethodAttributes.HideBySig) != 0))  

    as well as starts with get_ or set_ then you should be good even for people using nasty names (faking the hidebysig is easy enough, faking the IsSpecialName would be very tricky)

    Nothing is guaranteed though. Someone could emit a class with a set_Foo method that looked just like a real set method but actually wasn’t a set on a read only property. Unless you check whether the property CanRead/CanWrite as well.

    This strikes me as madness for you though you aren’t expecting deliberate circumvention. A simple utility/extension method on MethodInfo which did this logic wouldn’t be too hard and including IsSpecialName would almost certainly cover all your needs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 98k
  • Answers 98k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The general idea behind "Entry 'filename' not uptodate. Cannot merge."… May 11, 2026 at 7:36 pm
  • Editorial Team
    Editorial Team added an answer See this article on alistapart.com. (Ed: The article has been… May 11, 2026 at 7:36 pm
  • Editorial Team
    Editorial Team added an answer You need to reference NVelocity.dll. This doesn't seem to be… May 11, 2026 at 7:35 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.