DevForce Help Reference
PropertyInterceptorAction<TArgs> Constructor(Type,String,PropertyInterceptorMode,Action<TArgs>,Double,String)
Example 


Type of object on which the interceptor action is invoked
The name of the property on which the interceptor acts.
When the action is invoked
The action to be performed
The invocation order of the action
Uniquely identifies the action
Creates an instance of this class.
Syntax
'Declaration
 
Public Function New( _
   ByVal targetType As Type, _
   ByVal targetName As String, _
   ByVal mode As PropertyInterceptorMode, _
   ByVal action As Action(Of TArgs), _
   ByVal order As Double, _
   ByVal key As String _
)
'Usage
 
Dim targetType As Type
Dim targetName As String
Dim mode As PropertyInterceptorMode
Dim action As Action(Of TArgs)
Dim order As Double
Dim key As String
 
Dim instance As New PropertyInterceptorAction(Of TArgs)(targetType, targetName, mode, action, order, key)

Parameters

targetType
Type of object on which the interceptor action is invoked
targetName
The name of the property on which the interceptor acts.
mode
When the action is invoked
action
The action to be performed
order
The invocation order of the action
key
Uniquely identifies the action
Remarks
Use PropertyInterceptor<TInstance,TValue,TArgs>.AddAction or AddAction to add the action to an interceptor.
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

PropertyInterceptorAction<TArgs> Class
PropertyInterceptorAction<TArgs> Members
Overload List

Send Feedback