[CLOSED] How to recognize a DirectMethod in runtime?

  1. #1

    [CLOSED] How to recognize a DirectMethod in runtime?

    Hi,

    Could you please suggest an inexpensive way to determine if a method is Direct on the server? I need that for cases where control of flow execution goes into the code injected into a method context with post-compilation tools like PostSharp. For example, I'm able to detect DirectEvents by examining the method arguments - DirectEventArgs parameter is present then. With DirectMethods, there's apparently no such luxury. I'm thinking of enlisting the help of Reflection but looking for your recommendations.
    Last edited by Daniil; Sep 17, 2012 at 4:20 PM. Reason: [CLOSED]
  2. #2
    Hello,

    DirectMethods will have the [DirectMethod] Attribute attached to each method.
    Geoffrey McGill
    Founder
  3. #3
    Quote Originally Posted by geoffrey.mcgill View Post
    Hello,

    DirectMethods will have the [DirectMethod] Attribute attached to each method.
    Thanks Geoffrey! That was helpful. What approach would you recommend for DirectEvents, are they decorated with any attribute to examine?
  4. #4
    Quote Originally Posted by vadym.f View Post
    What approach would you recommend for DirectEvents, are they decorated with any attribute to examine?
    No, they are not. In addition, the DirectEventArgs is not required to use. The following handler will work as a DirectEvent handler.
    protected void TestDirectEventHandler(object sender, EventArgs e)
    {
        X.Msg.Alert("DirectEvent", "Hello from Server!").Show();
    }
    So, be careful to use your method to check "args" type.

    You could mark any DirectEvent handler with some attribute you wish, then check it.
  5. #5
    Quote Originally Posted by Daniil View Post
    No, they are not. In addition, the DirectEventArgs is not required to use. The following handler will work as a DirectEvent handler.
    protected void TestDirectEventHandler(object sender, EventArgs e)
    {
        X.Msg.Alert("DirectEvent", "Hello from Server!").Show();
    }
    So, be careful to use your method to check "args" type.

    You could mark any DirectEvent handler with some attribute you wish, then check it.
    I see. I hope as long as the dev team agrees to stick to the same DirectEvent signature having the DirectEventArgs parameter, we should be fine. Is my assumption correct?
  6. #6
    Quote Originally Posted by vadym.f View Post
    I hope as long as the dev team agrees to stick to the same DirectEvent signature having the DirectEventArgs parameter, we should be fine. Is my assumption correct?
    Generally, yes.

    But be careful about this:
    protected void Store_ReadData(object sender, StoreReadDataEventArgs e)
    It is also a DirectEvent, but StoreReadDataEventArgs is inherited directly from System.EventArgs.
  7. #7
    Quote Originally Posted by Daniil View Post
    Generally, yes.

    But be careful about this:
    protected void Store_ReadData(object sender, StoreReadDataEventArgs e)
    It is also a DirectEvent, but StoreReadDataEventArgs is inherited directly from System.EventArgs.
    It looks like the only reliable method of detecting DirectEvents in runtime would be by decorating them with a functionless custom attribute that we control. :(
  8. #8
    Unfortunately, yes, there is no generic way to determine the specified method is a DirectEvent handler or not.

    Marking them with your own attribute looks to be a single solution.
  9. #9
    Quote Originally Posted by Daniil View Post
    Unfortunately, yes, there is no generic way to determine the specified method is a DirectEvent handler or not.

    Marking them with your own attribute looks to be a single solution.
    Thanks Daniil! Please mark this question as resolved.

Similar Threads

  1. Replies: 0
    Last Post: Aug 23, 2012, 11:55 PM
  2. Replies: 1
    Last Post: May 09, 2012, 7:08 PM
  3. does not recognize the tag <model>
    By marco.amusquivar in forum 2.x Help
    Replies: 3
    Last Post: Mar 21, 2012, 4:06 PM
  4. Replies: 8
    Last Post: Dec 28, 2011, 4:07 AM
  5. [CLOSED] Difference between DirectMethod , DirectEvent, Static DirectMethod
    By syllabusarq in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 01, 2011, 11:37 AM

Tags for this Thread

Posting Permissions