In my application I previously used regular C# attributes to "annotate" a method. E.g.:
[Foo(SomeKey="A", SomeValue="3")]
[Foo(SomeKey="B", SomeValue="4")]
public void TheMethod()
{
SpecialAttributeLogicHere();
}
What SpecialAttributeLogicHere() did, was to reflectively look at all the Foo-attributes that annotated this particular method. It would then (on its own), create its own dictionary for all the keys and values.
I'm now trying to move to PostSharp, because the SpecialAttributeLogic could be put into an aspect (and removed from the method body which is much cleaner!), within OnEntry. Foo will be replaced by an aspect that extends OnMethodBoundaryAspect.
I would still like to use it the following way:
[Foo(SomeKey="A", SomeValue="3")]
[Foo(SomeKey="B", SomeValue="4")]
But if Foo has an OnEntry, that means that the "SpecialAttributeLogic" will be executed twice. I basically need to "gather" all the keys and values from each Foo(), into a dictionary, which I then apply some logic to.
How to do this (or best practices) with PostSharp? Thanks!