Adding Property Set Support

By default, CodeSmith Generator will try to serialize your custom metadata types automatically using the JSON.NET library. So for most situations, you won't need to do anything special to add CodeSmith Generator Project property serialization support.

If your custom metadata type does not work by default or requires special formatting to save to XML (for instance, it includes information that you want to format in a particular way in the XML file), you'll need to add a property serializer. Otherwise, there won't be any way for the user to save an XML property set file that includes an instance of your metadata type. To add property set support, you'll need to build a serializer for your type. A serializer is simply a class that implements the CodeSmith.IPropertySerializer interface.

You can find the source code for several CodeSmith Generator custom designers in your extracted template folder. The default template folder is located in the My Documents folder (Documents\CodeSmith Generator\Samples\<Version>\Projects\CSharp\CustomPropertiesSample\

For example, DropDownEditorProperty is a class that wraps up a string and a boolean value together into a single piece of metadata. To serialize this data, it provides a class, DropDownEditorPropertySerializer, which implements IPropertySerializer. The declaration of DropDownEditorProperty is decorated to indicate that this is the serializer class that CodeSmith Generator should use:

[PropertySerializer(typeof(CodeSmith.Samples.DropDownEditorPropertySerializer))|PropertySerializer(typeof(CodeSmith.Samples.DropDownEditorPropertySerializer))]
public class DropDownEditorProperty