Skip to content

XmlDataContractCodec

simonthorogood edited this page Dec 12, 2010 · 1 revision

OpenRasta supports serialization of a resource using XML Data Contract serialization. This is a fast, simple form of serialization that does not support attributes.

Registering the codec

Whenever you want to render a resource using the XmlDataContractCodec, use the following form:

ResourceSpace.Has.ResourcesOfType<Customer>()
                 /* your handler declaration */
                 .AsXmlDataContract();

This is shorthand for:
ResourceSpace.Has.ResourcesOfType<Customer>()
                 /* your handler declaration */
                 .TranscodedBy<XmlDataContractCodec>(null);

Serialization considerations

As with the JsonDataContractCodec, it is not necessary to decorate your resource type with System.Runtime.Serialization attributes such as DataContract and DataMember. Doing so, however, will allow finer control over the naming and ordering of the resulting output.

When to use

Use the XmlDataContractCodec when you want a fast, simple XML representation of a resource which does not use attributes.

Clone this wiki locally