In my application, I previously used regular C # attributes to “annotate” a method. For example:.
[Foo(SomeKey="A", SomeValue="3")] [Foo(SomeKey="B", SomeValue="4")] public void TheMethod() { SpecialAttributeLogicHere(); }
What SpecialAttributeLogicHere () did was to reflect all the Foo attributes that annotated this particular method. Then he (by himself) would create his own dictionary for all keys and values.
Now I'm trying to go to PostSharp, because SpecialAttributeLogic can be placed in the aspect (and removed from the body of the method, which is much cleaner!), Inside OnEntry. Foo will be replaced by an aspect that extends OnMethodBoundaryAspect.
I would still like to use it as follows:
[Foo(SomeKey="A", SomeValue="3")] [Foo(SomeKey="B", SomeValue="4")]
But if Foo has OnEntry, it means that "SpecialAttributeLogic" will execute twice. I basically need to “collect” all the keys and values from each Foo (), into a dictionary, into which I then apply some logic.
How to do it (or best practices) with PostSharp? Thanks!
c # aop postsharp
Tk
source share