Skip to main content

Property Names

Every property of a custom document node must have an associated identifier, a Property Name.


Each document node class must have an inner class called PropertyNames containing identifiers for public and internal properties:

  • If the node class derives from DocumentNode, the class should derive from DocumentNode.PropertyNames.
  • If the class derives from a sub class to DocumentNode, the property name class shall derive from
    [DocumentNode sub class].PropertyNames.

Implementation Pattern

Suppose we have a sealed document node class Example with the public property Title and the internal property NumberOfTicks, then the PropertyName class is defined as follows.

public sealed class Example : DocumentNode
	public new sealed class PropertyNames : DocumentNode.PropertyNames
       public static readonly PropertyName Title = CreatePropertyName("Title");
       internal static readonly PropertyName NumberOfTicks = CreatePropertyName("NumberOfTicks");

If the class is not sealed, the PropertyNames class should be made abstract. The string that is passed into the PropertyName constructor is used as a key in the serialization of the node and should by convention be the same as the name of the property. That is, it should use Pascal casing.

If the class contains private properties they should not be added to the PropertyNames class. Instead create a private class called, by convention, PrivatePropertyNames. The class should contain one public static field for each private property.