Advanced programming


You can declare properties (.NET properties) of classes in iPlus in two ways:

  • in the C# code,
  • or virtually via the iPlus development environment.

The term "virtual declaration" in iPlus should not be confused with the C# keyword "virtual". In iPlus, virtual declaration means that the definition of the property is done only in the SQL database (more specifically, in the ACClassProperty table) and not hard-coded in a .NET assembly. The decision whether to add properties by database or by C# code depends on various criteria. A blanket answer is not possible. Therefore, please read the following sections to better understand the underlying technology.

The following sections also deal with the following points in more detail:

  • Local or network properties
  • Source and target properties (property bindings)
  • ACPropertyInfo attribute class
  • Standard Values and Persistence
  • Serializable types and editors for complex types
  • Overwriting Properties
  • Long-term storage
  • Change events and handler programming
  • surface binding
  • Property grouping (Selected/Current/List/Access)
  • Special feature: Configuration variables

Virtual properties can be added via the iPlus development environment:

 

Select the project from the Explorer list and select the class in the project tree for which you want to define a new property.

  1. Klick the "New Property" button. A new entry appears in the property list where the property type is automatically set to "Virtual Property". (Fixed encoded properties from the assembly have the property type "Property")
  2. Assign a unique property name that must not contain any special characters.
  3. Describe the property in detail (this text is automatically displayed in front of text boxes or other controls). To enter the description in several languages, first enter the I18N prefix followed by a colon and then the text: e.g. "en:My Text"
  4. Define the data type of this property. This can be either primitive .NET types (system namespace) or more complex data types that you have defined yourself. If this property is to be persistent (point 6) or transmitted over the network, that it is serializable or has been provided with the  [ACSerializeableInfo] ant the [DataContract] attribute.
  5. Optional: In the Value field, specify the default value that the property should have when the instance is created by the iPlus framework. If the value is left blank, the property gets the .NET default value.
  6. Optional: Define whether this property is persistent. If it is, the value is written to the database for each change event (table ACClassTaskValue). The next time the iPlus service is started or the next time it is instantiated, the property receives the last value stored.
    Attention:
    1. The set default value (point 5) is ignored in this case.
    2. Complex data types must have the ACSerializeableInfo and the DataContract attribute, as already mentioned under point 4, so that they can be serialized be the iPlus DataContractSerializer.
  7. Optional: Set whether the property "Network enabled". Read more about this in the subchapter "Network".
  8. Optional: Set whether the property is a  "Data proxy/-target" variable. Read more about this in the subchapter "Network". This setting only applies to "Network capable" properties.
  9. Optional: Select the update rate at which the property changes are stored in the long-term archive. Read more about this in the subchapter "Long-term archive".

To be able to use your newly programmed properties from the assembly or C# code in iPlus, you must use one of the derivatives of the attribute class [ACPropertyBase].

See: Using Attributes

In addition, you must announce the class of the iPlus runtime as described in the chapter "Building own .NET-Classes".

Example code:

 

Use of different derivatives of the ACPropertyBase attribute class.

The properties are registered by holding down the left control key during iPlus login and pressing the login key with the left mouse button. The iPlus runtime then begins to examine all  assemblies located in the programm directory.

Only the properties are analyzed,

  • that are provided with attribute classes,
  • and the derivatives of ACPropertyBase (namespace gip.core.datamodel).

Derivates of the ACPropertyBase:

The listed attribute classes do not differ from their properties because they are all defined in the common base class ACPropertyBase. The different derivations only serve to make the program code more understandable and to simplify the constructors so that only the necessary construction parameters have to be passed. Therefore these attribute classes sometimes exist with different constructors. The individual classes are described in more detail in the following sections. The transferred construction parameters are transferred to the fields that you can see in the screenshot of the previous section (3, 5-8). Only the property name (2) and the data type (4) are automatically transferred from the method signature via .NET Reflection. The following properties are defined in the ACPropertyBase class:

ParameterBeschreibung
short SortIndex[Mandatory] Sort sequence of the listing of properties in the iPlus development environment. If the SortIndex is > 9999, this property is not displayed in the tool window of the designer.

string
ACGroup

[Mandatory] Used to assign related properties (List, Selected, and Current). Use an empty string for independent properties.

string
ACCaptionTranslation

[Mandatory] Translation tuple for the translation of the property. Syntax for translation tuple

  • I18N-Prefix: e.g. en, de, fr...
  • Curly bracket open and single apostrophe: {'
  • Text in corresponding language
  • Single apostrophe and curly bracket closing: '}

Example: en{'My english text'}de{'Mein deutscher Text'}

This text shall be entered in box (3) "Name". See screenshot from previous section.

Global.ACPropUsages
ACPropUsage

Usage of the Property.
object 
DefaultValue
[Optional] Default value that the property should have as soon as the instance is created by the iPlus framework. If the value is empty, the property receives the .NET default value. This value is entered in field (5) "Value". See screenshot from previous section.
bool
IsRightmanagement
[Optional] Properties with rights management, different access rights can be assigned for individual users or groups in the Rights management module.
bool IsPersistable[Optional] If the property is persistent, the value is written to the database for each change event (table ACClassTaskValue). The next time the iPlus service is started or the next time it is instantiated, the property receives the last value stored.
Attention:
  • The set default value (point 5) is ignored in this case.
  • Complex data types must have the ACSerializeableInfo and the DataContract attribute, as already mentioned under point 4, so that they can be serialized by the iPlus-DataContractSerializer.

This value is entered in field (6) "Saveable". See screenshot from previous section.

bool 
IsBroadcast
[Optional] If the property is network-capable, it is automatically distributed in the network when change events occur. This value is entered in field (7) "Distribute in Network". See screenshot from previous section. Read more about this in the subchapter "Network".
bool IsProxyProperty[Optional] If the property is a "proxy" property, it gets its value from a property binding from a source property. This value is entered in field (8) "Data proxy/destination". See screenshot from previous section. Read more about this in the subchapter "Network".
bool ForceBroadcast

[Optional] With ForceBroadcast there is always a distribution of the property in the network. Even if you have not changed the value of a network-capable property.

  • For network-enabled properties (destination or source): Whenever ValueT is set, a transmission to the clients takes place, even without changing the value.
  • For local properties: If set, the proxy retrieves the value only once. There is never an update on the proxy side.
string
ACSource
 [Optional] If the property can be displayed and selected in an ItemsControl, the ACUrl for an ItemsSource can be specified here.
Type
ConfigDataType
[Optional] If the ACPropUsage has the value ConfigPointConfig or ConfigPointProperty, the property value or the list entries are stored in the table ACClassConfig. The data type must be specified so that the serializer recognizes which data type must be serialized and the iPlus development environment knows which editor is to be used in the "Configuration" tab.
int
MinLength
[Optional] Minimum number of characters if the data type of the property is a string.
int
MaxLength
[Optional] Maximum number of characters if the data type of the property is a string.
double
MinValue
[Optional] Minimum allowed value.
double MaxValue[Optional] Maximum allowed value.

 


For each property of a class, regardless of whether it exists as C# code in an assembly or whether it was defined virtually using the iPlus development environment, the iPlus framework creates an instance of the generic class ACProperty<T> or one of its derivatives. See the following UML diagram:

 

The ACProperty<T> class has a ValueT property that encapsulates the actual value. You can use it to read or set the value. For properties that have been defined as normal C# properties, the corresponding setter or getter method is automatically called in the background.

To get a reference to an ACProperty<T>, call the method IACPropertyBase GetProperty(string acName) and pass the name of the property. All properties of a class are provided in the List<IACPropertyBase> ACPropertyList of an ACComponent. You can therefore also access this list and search for its property yourself using LINQ.

The IACPropertyBase interface allows type-neutral access to a property if the data type is not known to the application programmer. The object Value property can also be used to access the value via Boxing/Unboxing. However, we recommend that you always work with the generic variant, because this prevents type runtime errors.

Therefore cast the IACPropertyBase into an IACContainerT<T> reference and always work with it!

The background why you should rather work with an IACContainerT<T> reference is because due to the network abstraction capability of the iPlus framework different derivatives of the ACProperty<T> class can be hidden and you should not be bothered with them during programming (see diagram above).

Network-compatible or local properties are discussed in more detail in the following subchapters.