Up Property interceptors
DevForce Resource Center » Development guide » Model » Property interceptors » Dynamic property interception and the PropertyInterceptorManager

Dynamic property interception and the PropertyInterceptorManager

Last modified on April 05, 2017 16:22

The PropertyInterceptorManager is the container managing property interceptor actions within DevForce.  A developer accesses the PropertyInterceptorManager via its CurrentInstance property.


Dynamic property interception

The CurrentInstance holds all currently registered interceptor actions.  You can query for existing actions, and add and remove property interceptor actions.  

To directly add actions to the PropertyInterceptorManager, use the AddAction method. For example, this adds a "before set" auditing method to every entity property:

C#
PropertyInterceptorManager.CurrentInstance.AddAction(
 new PropertyInterceptorAction<PropertyInterceptorArgs<Entity,Object>>(
   typeof(Entity), null, PropertyInterceptorMode.BeforeSet,
    (args) => Debug.WriteLine("Entity BeforeSet"), 0.0, "A")
);
VB
PropertyInterceptorManager.CurrentInstance.AddAction( _
 New PropertyInterceptorAction(Of PropertyInterceptorArgs(Of Entity, Object)) _
    (GetType(Entity), Nothing, PropertyInterceptorMode.BeforeSet, _
    Function(args) Debug.WriteLine("Entity BeforeSet"), 0.0, "A"))

Recursive interceptor actions

Recursion within a property interceptor can occur when the interceptor action invokes another property get or set which triggers execution of the same interceptor - this might occur, for example, when an interceptor action accesses the same property on a super- or sub-class.  By default, recursive execution is disabled.  

For use cases which require recursive execution of an interceptor, set the AllowRecursiveIntereceptors flag to true.  For example:

C#
PropertyInterceptorManager.CurrentInstance.AllowRecursiveInterceptors = true;
Created by DevForce on October 07, 2010 14:19

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2015 IdeaBlade