Up Property interceptors
DevForce Resource Center » Development guide » Model » Property interceptors » Multiple attributes on a single interceptor action

Multiple attributes on a single interceptor action

Last modified on October 27, 2011 13:02

There will be cases where you want a single interceptor action to handle more than one property but less than an entire class. In this case, it may be useful to write an interceptor action similar to the following:

C#
[BeforeSet(EntityPropertyNames.FirstName)]
[BeforeSet(EntityPropertyNames.LastName)]
public void UppercaseName(
  IbCore.PropertyInterceptorArgs<Employee, String> args) {
  var name = args.Value;
 if (!String.IsNullOrEmpty(name)) {
    args.Value = args.Value.ToUpper();
  }
}
VB
<BeforeSet(EntityPropertyNames.FirstName), BeforeSet(EntityPropertyNames.LastName)> _
Public Sub UppercaseName(ByVal args As  _
  PropertyInterceptorArgs(Of Employee, String))
 Dim name = args.Value
 If Not String.IsNullOrEmpty(name) Then
    args.Value = args.Value.ToUpper()
 End If
End Sub
Created by DevForce on October 07, 2010 13:26

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2020 IdeaBlade