Accessing Parameter Value with Attribute

  • Thread starter Thread starter Larry R
  • Start date Start date
L

Larry R

Is there any way to use a custom attribute class to use a parameter of
the tagged method?

For instance,

[LogThis ( user) ]
public TagThis ( string user )
{
....
}

Larry R
 
Larry,

No, there is not. Attributes don't have a sense of what they are
attached to. That logic will have to be outside of the attribute.
 
It sounds like you might want "AOP". C# does not support this "out of
the box", but there are multiple implementations available. I don't
want to recommend any as I haven't used any of them enough to give a
sensible answer.

Marc
 
Back
Top