Code before the first "try"

Do you program directly PostSharp.CodeModel or another low-level API and need help? Put your questions here and we will try to answer.

Code before the first "try"

Postby Ed_ward on Sun Feb 10, 2008 9:19 pm

Hi Gael

Please tell me what should I do to generate code before the first "try" from advice which uses JoinPointKinds.BeforeMethodBody, JoinPointKinds.AfterMethodBodyException and JoinPointKinds.AfterMethodBodyAlways?

I want to insert :
void SomeMethod()
{
// some code here
try
{
// some code here
}
catch(Exception exc)
{
// some code here
}
finally
{
// and some code here
}
}

Ed.ward
Edward Pavlov
Ed_ward
 
Posts: 11
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Edward Pavlov

Re: Code before the first "try"

Postby gfraiteur on Mon Feb 11, 2008 3:28 pm

You could use two instances of IAdvice and use different priorities. The most external advice will be the "on before". It should work.

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 674
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org


Return to PostSharp Core