Attributes

  • Thread starter Thread starter Zviki Goldberg
  • Start date Start date
Z

Zviki Goldberg

Hi All...

I have a Auditing system. I want to send Audit messages using attributes. I
managed to activate the ContextAttribute object, BUT it forced me to inherit
from ContextBound object (which is too much for me, cause I want to use this
attribute auditing also in web pages).
Is there any option to do so ?
Maybe the solution is somewhere in the Demand staff (.NET rle base
security).... How is that check enabled ??

Thanks a lot,...

Zviki.
 
You can apply attributes to any construct specified in AttributeTargets.
The thing is, they don't automatically execute, as they are merely
attributes. Certain attributes appear to do so (like
SoapExtenstionAttribute and ContextAttribute) because a superclass has a
method call that introspects the construct to search for appropriate
attributes of a certain type and acts upon them. So, to make a long story
short, the only way you can have certain web pages execute an attribute is
to insert it into an already-existing attribute-checking infrastructure
(again, SoapExtensionAttribute is a fine example, as the web service
superclass automatically looks for SoapExtentionAttributes)
Another avenue is to put some code to look for and deal with attributes in
some central method call (an MSDN search for SqlParameterAttribute will
produce an article illustrating this)
 
Zviki Goldberg said:
Hi All...

I have a Auditing system. I want to send Audit messages using attributes. I
managed to activate the ContextAttribute object, BUT it forced me to inherit
from ContextBound object (which is too much for me, cause I want to use this
attribute auditing also in web pages).

Why is this a problem? In an auditing system you want to get informed when
an object method is called. By creating a new context you are defining a
context boundary that must be crossed when method calls are made, hence you
can intercept those calls and do your auditing. The is procisely what
contexts are for (allowing you to intercept method calls).

Have a look at this magazine article for more details (or even buy Juval
Lowy's recent book on .NET Components):

http://msdn.microsoft.com/msdnmag/issues/03/03/ContextsinNET/

Richard
 
Back
Top