Advanced programming


With storable properties, you can ensure that after an unexpected program crash or the more regular termination of the iPlus-service, the state is restored after the service is restarted.

For a property to be storable (persistent), you must set the IsPersistable property of the various ACPropertyBase attribute classes to True.

The save operation is performed immediately (asynchronously) when calling the setter method (by calling the OnPropertyChanged() method) or when changing the ValueT property of network-capable properties.

On the other hand, the iPlus framework performs the recovery by calling the setter method once at startup with the value that was last stored in the database.

From a technical point of view, serialization or deserialization always takes place when writing or reading using the DataContractSerializer. The serialized string is stored in the property XMLValue of the table ACClassTaskValue. Therefore, only data types that have been previously made known to the DataContractSerializer can be stored.


For serialization iPlus uses the DataContractSerializer from .NET. The DataContractSerializer is not only used to persist the properties but also for network transmission (client/server). In both cases, all types that are to be stored or transmitted over the network must be made known to the DataContractSerializer in the KnownTypes property.

However, the iPlus framework simplifies this for you by only having to use the attribute class ACSerializeableInfo. Declare it before a ACComponent-Class where you want to use this type:

bleInfo(new Type[] { typeof(ACMaintWarning), typeof(List<ACMaintWarning>), typeof(List<ACMaintDetailsWarning>) })]

Exaple for  Smart-Pointer:

[ACSerializeableInfo(new Type[] { typeof(ACRef<Weighing>) })]

You must also describe the types with the DataContract- and DataMember-Attribut classes  as the WCF specifies.

 

 

 


Attention: Avoid this with Entity objects! Entity objects should be read and written manually by using your own ObjectContext or DatabaseContext. Read more about this in the section "Database Contexts and Entity Framework".