Visual Basic (Declaration) | |
---|---|
Public Class PropertyInterceptor (Of TInstance,TValue,TArgs As PropertyInterceptorArgs(Of TInstance,TValue)) Inherits PropertyInterceptor |
Visual Basic (Usage) | ![]() |
---|---|
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> |
- TInstance
- Type of object
- TValue
- Type of property value
- TArgs
- Type of arguments to actions
C# | ![]() |
---|---|
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"); } } |
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.
System.Object
IdeaBlade.Core.PropertyInterceptor
IdeaBlade.Core.PropertyInterceptor<TInstance,TValue,TArgs>
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