Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

If your custom metadata 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 property set support. 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 several examples of implementing custom designers in the SampleCustomProperties project in the SampleProjects folder installed by CodeSmith. 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 should use:

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