Hi all,

Does anyone know how to intercept and *identify* a call to a 'Field or
Propery' of a ContextBoundObject that implements a seperate custom
Attribute.

I've successfully accomplished this on a method call on the ContextBound
object where the Target Class implements a IContextBoundAttribute and the
method implements a seperate custom attribute - simple attribute, not
IContextBoundAttribute. - No Problems here.

On Field/Property Level - The call is intercepted to the field/property,
but I cannot tell if this field or property is marked with my desired
attribute. GetCustomAttributes() list on a 'Field or Property' call
interception always returns empty.

I'm including my interception code in my custom message sink:

  private void InterceptAccess(IMethodMessage msg)
  {

   MethodBase methodInfo = msg.MethodBase;

   object[] arrayOfCustomAttributes =
methodInfo.GetCustomAttributes(true);

   object[] tt = methodInfo.GetCustomAttributes(typeof
(TestAttribute),true);
}

IMessage is passed to this function as IMethodMessage from
SyncProcessMessage(IMessage msg). Property/Fields are marked
with 'TestAttribute' in the target ContextBoundObject. In the above code,
both arrayOfCustomAttributes and tt arrays return empty, so I cannot
identify if the property/field being intercepted are the ones I'd like to
identify.

Note the above code returns the Custom Attributes if it's a *Method Call*
with an Attibute with [AttributeUsage(AttributeTargets.Method)].

What am I missing?

Thanks very much for any feedback and yours codefully,

Yigosan

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to