DevForce Help Reference
AfterSetAttribute Class
Members  Example 


Marks an action to be performed in a property setter after the value is written to the backing store.
Syntax
'Declaration
 
<AttributeUsageAttribute(ValidOn=AttributeTargets.Method, 
   AllowMultiple=True, 
   Inherited=True)>
Public Class AfterSetAttribute 
   Inherits PropertyInterceptorAttribute
   Implements System.Runtime.InteropServices._Attribute 
'Usage
 
Dim instance As AfterSetAttribute
[AttributeUsage(ValidOn=AttributeTargets.Method, 
   AllowMultiple=true, 
   Inherited=true)]
public class AfterSetAttribute : PropertyInterceptorAttribute, System.Runtime.InteropServices._Attribute  
Remarks
Use AfterSet to specify one or more actions to be performed when a property setter is invoked. These actions occur after the backing value has been written. Actions may be defined as instance or static methods on a base or derived type. The execution order may be specified by using the Order named parameter. See the Developer's Guide for more information on action chaining and ordering. AfterSet interceptor actions are automatically discovered the first time a property setter is called.

There are a number of acceptable signatures for methods marked with this attribute. In general, you can accept (or accept and return) an object of the expected property type, or accept one of the many derivations of PropertyInterceptorArgs. See the examples provided with the constructors for more information. If a signature is invalid, you will receive a PropertyInterceptorException when DevForce either builds or tries to execute the method, depending on when detected.

Example
public partial class Customer {

  // Sample signatures for a AfterSet method for any Customer property
  // (invoked for both simple and navigation properties).
  // Additional signatures are possible.

  // Although you can change args.Value in an AfterSet method, the backing store
  // is not modified, but the modified value will be passed to subsequent AfterSet actions.
  // Setting args.Cancel in an AfterSet also does not affect the backing store,
  // but does stop subsequent actions from being executed.

  // Signature 1 - accept a property value and return a property value.
  // Any value returned is passed to next action but does not affect the 
  // backing store.
  [AfterSet]
  public object AfterSetAnyCustomerProperty1(object value) {
    Console.WriteLine("After setting a customer property 1");
    return value;
  }

  // Signature 2 - accept a property value, but no return value.
  [AfterSet]
  public void AfterSetAnyCustomerProperty2(object value) {
    Console.WriteLine("After setting a customer property 2");
  }

  // Signature 3 - accept base IPropertyInterceptorArgs.
  // Allows you to cancel further actions and modify the Value.
  // No property information available.
  [AfterSet]
  public void AfterSetAnyCustomerProperty3(IPropertyInterceptorArgs args) {
    Console.WriteLine("After setting a customer property 3");
  }

  // Signature 4 - accept EntityProperty interceptor arguments.
  // The arguments passed allow you to determine the property retrieved
  // and to cancel further actions. 
  [AfterSet]
  public void AfterSetAnyCustomerProperty4(IEntityPropertySetInterceptorArgs args) {
    Console.WriteLine("After setting a customer property 4");
  }

  // Signature 5 - accept strongly-typed IPropertyInterceptorArgs.
  // Same features as IPropertyInterceptorArgs but Instance is now strongly-typed.
  [AfterSet]
  public void AfterSetAnyCustomerProperty5(IPropertyInterceptorArgs<Customer, object> args) {
    Console.WriteLine("After setting a customer property 5");
  }
}
Inheritance Hierarchy

System.Object
   System.Attribute
      IdeaBlade.Core.PropertyInterceptorAttribute
         IdeaBlade.Core.AfterSetAttribute

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

AfterSetAttribute Members
IdeaBlade.Core Namespace
PropertyInterceptorArgs Class
PropertyInterceptorAction Class

Send Feedback