TInstance
Type of object
TValue
Type of property value
TArgs
Type of arguments to actions
IdeaBlade DevForce 2010 Help Reference
PropertyInterceptor<TInstance,TValue,TArgs> Class
Members  Example  See Also  Send Feedback
IdeaBlade.Core Assembly > IdeaBlade.Core Namespace : PropertyInterceptor<TInstance,TValue,TArgs> Class



Used to add custom actions to property getters and setters.

Syntax

Visual Basic (Declaration) 
Public Class PropertyInterceptor
    (Of TInstance,TValue,TArgs As PropertyInterceptorArgs(Of TInstance,TValue)) 
   Inherits PropertyInterceptor
Visual Basic (Usage)Copy Code
Dim instance As PropertyInterceptor(Of TInstance,TValue,TArgs)
C# 
public class PropertyInterceptor<TInstance,TValue,TArgs> : PropertyInterceptor 
where TArgs: PropertyInterceptorArgs<TInstance,TValue>
C++/CLI 
generic<typename TInstance>
generic<typename TValue>
generic<typename TArgs>
public ref class PropertyInterceptor : public PropertyInterceptor 
where TArgs: PropertyInterceptorArgs<TInstance,TValue>

Type Parameters

TInstance
Type of object
TValue
Type of property value
TArgs
Type of arguments to actions

Example

C#Copy Code
public void Sample() {
     
      // Sample showing a mix of attribute and dynamic actions, on both base and derived types.
  
      // Add dynamic actions on Entity to affect any property:
      PropertyInterceptorManager.CurrentInstance.AddAction(
        new PropertyInterceptorAction<PropertyInterceptorArgs<Entity, Object>>(
          typeof(Entity),
          null,
          PropertyInterceptorMode.BeforeSet,
          (args) => Console.WriteLine("Entity BeforeSet"),
          0.0, "A"));

      PropertyInterceptorManager.CurrentInstance.AddAction(
        new PropertyInterceptorAction<PropertyInterceptorArgs<Entity, Object>>(
          typeof(Entity), 
          null,
          PropertyInterceptorMode.AfterSet,
          (args) => Console.WriteLine("Entity AfterSet"),
          0.0, "B"));

      // Look at all before set actions affecting customer company name
      foreach (var action in Customer.CompanyNameEntityProperty.SetterInterceptor.GetActions(typeof(Customer), PropertyInterceptorMode.BeforeSet)) {
        Console.WriteLine(action.Key + ", order = " + action.Order);
      }
      // Now look at all after set actions affecting customer company name
      foreach (var action in Customer.CompanyNameEntityProperty.SetterInterceptor.GetActions(typeof(Customer), PropertyInterceptorMode.AfterSet)) {
        Console.WriteLine(action.Key + ", order = " + action.Order);
      }
      
      // Now get a customer entity and set company name - see output for actions invoked.
      DomainModelEntityManager mgr = DomainModelEntityManager.DefaultManager;
      Customer c1 = mgr.Customers.First();
      c1.CompanyName = "Books N Things";
    }
    
public partial class Customer {

  [BeforeSet(Key = "CustomerBeforeAction1")]
  public void BeforeSetAnyCustomerProperty(IEntityPropertySetInterceptorArgs args) {
    Console.WriteLine("Customer any - before setting " + args.EntityProperty.Name);
  }

  [BeforeSet("CompanyName", Key = "CustomerBeforeAction2")]
  public void BeforeSetCompanyName(IEntityPropertySetInterceptorArgs args) {
    Console.WriteLine("Customer companyname - before setting company name");
  }

  [AfterSet(Key="CustomerAfterAction1")]
  public void AfterSetAnyCustomerProperty(IEntityPropertySetInterceptorArgs args) {
    Console.WriteLine("Customer any - After setting " + args.EntityProperty.Name);
  }

  [AfterSet("CompanyName", Key="CustomerAfterAction2")]
  public void AfterSetCompanyName(IEntityPropertySetInterceptorArgs args) {
    Console.WriteLine("Customer companyname - After setting company name");
  }
}

Remarks

Every EntityProperty has a GetterInterceptor, and if not returning a list of related entities, a SetterInterceptor.

Any number of PropertyInterceptorActions may be defined for each interceptor. You add these actions using attributes and AddAction(PropertyInterceptorTiming,Action<TArgs>).

You may also define PropertyInterceptors and actions on non-Entity types.

Inheritance Hierarchy

System.Object
   IdeaBlade.Core.PropertyInterceptor
      IdeaBlade.Core.PropertyInterceptor<TInstance,TValue,TArgs>

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.