DevForce Help Reference
AddAction Method (PropertyInterceptorManager)
Example 


Adds a property interceptor action.
Syntax
'Declaration
 
Public Sub AddAction( _
   ByVal interceptorAction As PropertyInterceptorAction _
) 
'Usage
 
Dim instance As PropertyInterceptorManager
Dim interceptorAction As PropertyInterceptorAction
 
instance.AddAction(interceptorAction)
public void AddAction( 
   PropertyInterceptorAction interceptorAction
)

Parameters

interceptorAction
Example
public void Sample() {

  // Add a BeforeGet action on Employe.Address  
  var piAction = new PropertyInterceptorAction<DataEntityPropertyGetInterceptorArgs<Employee, String>>(
            typeof(Employee),
            Employee.EntityPropertyNames.Address,
            PropertyInterceptorMode.BeforeGet,
            TraceGetter);
  PropertyInterceptorManager.CurrentInstance.AddAction(piAction);

  // Add a BeforeSet action on Employee.Country
  var piAction2 = new PropertyInterceptorAction<DataEntityPropertySetInterceptorArgs<Employee, String>>(
      typeof(Employee),
      Employee.EntityPropertyNames.Country,
      PropertyInterceptorMode.BeforeSet,
      TraceSetter);
  PropertyInterceptorManager.CurrentInstance.AddAction(piAction2);

  // Get/set a few properties
  DomainModelEntityManager mgr = DomainModelEntityManager.DefaultManager;
  Employee e = mgr.Employees.First();
  string addy = e.Address;
  e.Country = "UK";
}
    
public static void TraceGetter(DataEntityPropertyGetInterceptorArgs<Employee, String>> args) {
  Console.WriteLine("getter called for " + args.DataEntityProperty.Name);
}

public static void TraceSetter(DataEntityPropertySetInterceptorArgs<Employee, String>> args) {
  Console.WriteLine("setter called for " + args.DataEntityProperty.Name);
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

PropertyInterceptorManager Class
PropertyInterceptorManager Members

Send Feedback