DevForce Help Reference
AddAction(PropertyInterceptorTiming,Action<TArgs>) Method
Example 


Adds an action to the interceptor.
Syntax
'Declaration
 
Public Overloads Sub AddAction( _
   ByVal timing As PropertyInterceptorTiming, _
   ByVal action As Action(Of TArgs) _
) 
'Usage
 
Dim instance As PropertyInterceptor(Of TInstance,TValue,TArgs)
Dim timing As PropertyInterceptorTiming
Dim action As Action(Of TArgs)
 
instance.AddAction(timing, action)

Parameters

timing
action
Example
public void Sample() {

  // Add a BeforeGet action to a GetterInterceptor:
  Employee.PropertyMetadata.Address.GetterInterceptor.AddAction(
    PropertyInterceptorTiming.Before,
    TraceGetter);

  // Add a BeforeSet action to a SetterInterceptor:
  Employee.PropertyMetadata.Country.SetterInterceptor.AddAction(
    PropertyInterceptorTiming.Before,
    TraceSetter);

  // 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(IEntityPropertyGetInterceptorArgs args) {
  Console.WriteLine("getter called for " + args.EntityProperty.Name);
}

public static void TraceSetter(IEntityPropertySetInterceptorArgs args) {
  Console.WriteLine("setter called for " + args.EntityProperty.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

PropertyInterceptor<TInstance,TValue,TArgs> Class
PropertyInterceptor<TInstance,TValue,TArgs> Members
Overload List

Send Feedback