Property bindings defined by the iPlus development environment are stored in the ACClassPropertyRelation table with the ConnectionTypeIndex = 11 (Global.ConnectionTypes.ConnectionPhysical). During the initialization phases (ACInit und ACPostInit), these table entries are read and the properties are bound together.
Binding properties via the iPlus development environment can be very time-consuming if you have to bind many properties. There are two possible solutions:
- You program your own business object or a plug-in for the iPlus development environment that automatically makes entries in the ACClassPropertyRelation table via database access.
- or you dynamically bind the source and target properties during the initialization phase of your ACComponent class. This is explained in more detail in the following code example:
Always after ACPostInit()!
In line 2. BindMyProperties() is made after calling base.ACPostInit(). Only then it is guaranteed that all instances are available and a dynamic binding is possible.
Interface IACPropertyNetTarget
In the UML diagram of the properties section it can be seen that for properties provided by the [ACPropertyBindingTarget] another property class is used by the framework that implements the interface IACPropertyTarget. Usually an instance of the class ACPropertyNetTarget<T> is generated here. The IACPropertyTarget provides a property "Source" which can be used to query whether a source property is already bound (see line 3).
Interface IACPropertyNetSource
Properties that are provided with the [ACPropertyBindingSource] are instantiated using the ACPropertyNetSource<T> class, which implements the IACPropertySource interface. The IACPropertySource provides a property "Targets" to query whether specific target properties are bound (see line 5).
Dynamic Binding
To bind a target property to a source property, use the BindPropertyToSource() method, which is available with two overloads:
public PropBindingBindingResult BindPropertyToSource(IACPropertyNetSource acPropertySource, PropBindingMode bindingMode = PropBindingMode.BindAndBroadcast)
This method only binds properties that are of the same data type (type of ValueT). If the data types are different, PropBindingBindingResult.NotCompatibleTypes is returned.
public PropBindingBindingResult BindPropertyToSource(IACPropertyNetSource acPropertySource,
out IACPropertyNetTarget newTarget, out string message,
bool bindInDBIfConverterNeeded = true, PropBindingMode bindingMode = PropBindingMode.BindAndBroadcast)
This method first calls method (a). If the data types are incompatible, the method generates either
- a new target property of the class ACPropertyNetTargetConverter<T,S> and replaces the current reference (the method returns PropBindingBindingResult.TargetPropReplaced)
- or it modifies/repairs the data type of the source property. In this case, the iPlus service must be restarted for this change to become active. You can recognize this by the return value PropBindingBindingResult.TypeOfSourceWasChanged.