CLR Attributes are used to control how CLR types are serialized and identified by CIPl.
The presence of this attribute indicates that the associated type is visible to CIPl. Code for all the types in an assembly with a CIP4Item attribute will be included in the generated serializer. For example:
[CIP4Item(AddAllProperties = true, Collection = "People")] public class PersonType { [CIP4ExternalID] public string Name { get; set; } public AddressType Address { get; set; } public DictionaryAlternateAddresses { get; set; } public Dictionary Tags { get; set; } public Stream Portrait { get; set; } }
The attribute has the following properties:
This is the name that will be used in building the xml representation of the item. By default this is the same as the name of the type the attribute is attached to Use this property if you have more than one CIP4 collection of the same type.
This is the collection that instances of this account will be found in and saved to, If this property is not specified the type name will be used as the default value.
If true - all properties in the class will be used in serialization and deserialization
If supplied, this will be used as the domain part of the version namespaces used to identify the version of serialized objects - for example if VersionDomain is foo.com the CIPl item namespace used when serializing the item in xml will be http://foo.com/CIPlItem1.xsd
If true, the associated type will not be serialized and will not be included in any generated serializer
If supplied, this is the name that will be used in serializing an instance of the type. By default the SerializeAs name is the class name.
In the absence of AddAllProperties on the CIP4Item attribute, only properties with the CIP4Property attribute will be serialized.
[CIP4Property(IsIndexed=true)]
public Dictionary
The attribute has the following properties:
This determines the order in which the property appears in the serialization.. If Ordinal is not specified the properties will be serialized in alphabetical order. Any properties with the same Ordinal will be ordered firstly by Ordinal and then by name. The value zero will be ignored.
If true, the associated property will not be serialized.
If true, the target type for the property will be serialized even if it does not have a CIP4ItemAttribute.
If true - indicates to any underlying DataProvider that the property sould be indexed if possible
If supplied, this is the name that will be used in serializing property values. The default value is the proeprty name.
Every CIP4Item type must have one or more properties with the ExternalID attribute associated with them. The properties are concatenated (using an '_' charcater) to make up the externalID value that is used to identify the item. Two items with the same ExternalID value are considerted to be the same item. The ExternalID atribute has one property
Indicates the sequence in which the ExternalID properties are concatenated to make up the ExternalID value. If rank is not specified, the ExternalID properties will be concatenated in alphabetical order (by property name).
The associated property is used as the version property for the item. This is the property that controls optmistic concurrency behavior - it's value is checked before update to ensure that the item has not been changed since it was last read. The property must be either DatetTime or Int64