<< Click to Display Table of Contents >> NShape Programmer Tasks
|
The persistency mechanism requires information on the names, the order and the data type of the shape type's properties. This information is created by the static method GetPropertyDefinitions. Due to the fact that static methods can neither be part of an interface nor overridden, the implementing class has to 'override' GetPropertyDefinitions using the "new" keyword.
The base class' property definitions have to be returned before the implementing class returns its own property definitions.
new public static IEnumerable<EntityPropertyDefinition> GetPropertyDefinitions(int version) { |
It is assumed here that MyBaseShape is the base class of this shape class. Note, that it is important that the order of the properties is absolutely identical to the order in which they are written and read in the SaveFields and SaveInnerObjects methods.
As you can see in the example above, there is a version parameter that specifies the version of the repository. Every time you add features to your shapes, you should keep in mind that there are repositories out there saved with older versions of your library. In order to maintain backwards compatibility, you should check the version parameter before reading the new properties.