This creates an object model that makes it easier to use a DataStore from a .Net language such as C#.
<#@ DataStoreCodeGenerator Processor="Semata.CodeGeneratorDirectiveProcessor" #> <# GenerateObjectModel("OrderProcessing.ds", "OrderProcessing"); #>
DataStore Class
A class will be generated for the DataStore, which will inherit from DataStoreObject.
This class will have a property for each ItemType of type ItemObjects<I>. This will allow access to all the Items of that ItemType, and new Items to be created.
It will also have methods to Create, Open and Close the DataStore, with 2 partial method call backs: AfterCreate; BeforeOpen.
AfterCreate is intended for initial loading of the DataStore. BeforeOpening for updating the DataStore. Both will have a path to the DataStore passed. Each will have to open the DataStore, perform the necessary operations, then close the DataStore, using only the classes and methods found in Semata.DataStore.
ItemObject Class
A class will be generated for each ItemType, and that class will inherit from ItemObject. Each instance of this class represents an Item of the given ItemType. This class will be sealed, and not capable of being constructed directly. Instances will be returned by methods of the object model. There will only be one instance per Item.
This class will have a property for each AttributeType and AssociationType of the ItemType from which it is generated.
Attribute Properties
The properties based on AttributeTypes will be of type AttributeProperty< value-type > and have the name attribute-name Property. There will be another property, attribute-name , that will have the type of the actual Attribute, and give access to MISSING PAGE ValuePropertyImpl<T>.Value
Association Properties
The properties based on AssociationType can be implemented in 2 different ways. If an Item can have no more than one association of a particular AssociationType, then it can be implemented in a similar manner to an Attribute, otherwise it will be implemented as a collection.
This is controlled by the annotation on AssociationType. If the annotation contains the member �semata.datastore.object� with the element �property�, then the AssociationType will be implemented as an AssociationProperty< association name > in a similar to that of an Attribute. If it does not, then it will be implemented as an Association< association name >, which provides methods to add and remove Associations.
The class can be extended by implementing the following partial methods
OnInitialize() | Called at the end of the constructor |
OnValidate() | Called by Validate() and Write() to perform validation. If errors occur it should add them to the error collection using AddError(string propertyName, string error); |
OnCanDelete() | Called by MISSING PAGE ItemObject.CanDelete() and Delete() to check deletion is allowed. If errors occur it should add them to the error collection using AddError(string propertyName, string error); |
OnDeleting() | This is called before the Item is deleted. If errors occur they should throw an exception. |
OnCreated() | This is called after the Item is created. If errors occur they should throw an exception. |
OnWriting() | This is called before all the ItemObject's properties are written. If errors occur they should throw an exception. |
OnWritten() | This is called after all the ItemObject's properties are written. If errors occur they should throw an exception. |
On<property name>Changed(ref object value) | This is called when an ItemObject's property is changed. If errors occur it should add them to the error collection using AddError(string propertyName, string error); |
On<property name>Writing(ref object value) | This is called when an ItemObject's property is written. If errors occur they should throw an exception. |