MethodExecutionArgs.Arguments

isubhan's Avatar

isubhan

25 Apr, 2018 10:59 AM

Hello
I am new to PostSharp and trying it out for the first time.

I am trying to write code to add custom object in actual method which can be accessed in OnSuccess. How should I do this?

For Example
       [LoggingAspect]
        public void TestAudit(int x, int y, int z)
        {
            int a = x;
            int b = y;
            int c = z;

            Test obj = new Test() { Id = "12345", Name = "Irfon Subhan" };
           //How do I send this object to OnSuccess

        }

According to the below discussion post we can use MethodExecutionArgs.Arguments to set but can you give me an example
http://support.sharpcrafters.com/discussions/questions/698-accessing-local-varibales-in-a-method

Thank you

Regards,
Irfon

  1. Support Staff 1 Posted by PostSharp Techn... on 26 Apr, 2018 03:48 PM

    PostSharp Technologies's Avatar

    Hello,

    The code inside your method cannot pass anything directly into the aspect code. It's important to note that such approach would be against the principles of the aspect oriented programming model. You should try to design your code in such a way that it is not aware of the aspects applied to it.

    The OnMethodBoundaryAspect can access the method arguments, return value and the object instance on which the method is called. For more details about OnMethodBoundaryAspect please refer to this documentation page: http://doc.postsharp.net/method-decorator

    You can also develop more advanced aspects that access properties and other members of the target type. You can find the documentation on this page: http://doc.postsharp.net/members

    Please also note that we can provide only limited support to our community users on this forum. Please consider asking the question on StackOverflow and tag it with 'PostSharp' keyword (http://stackoverflow.com/questions/tagged/postsharp) or login into support forum with your commercial license.

    Best regards,
    Alex

  2. Support Staff 2 Posted by PostSharp Techn... on 28 May, 2018 12:11 PM

    PostSharp Technologies's Avatar

    Hello,

    We are going to close this request as we believe it was solved. Please feel free to reopen the discussion if you need more help.

    Best regards,
    PostSharp Team

  3. PostSharp Technologies closed this discussion on 28 May, 2018 12:11 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac