TracNav
OpenRasta's Documentation...
- Release Notes
- FAQs
Downloading/Building OpenRasta...
- Download from source
- Download the binaries
- Run the test suite
- .NET versions support
Using OpenRasta...
- Configuration how-tos
What you need to know about dependency injection
Tutorials
Building web-sites with OpenRasta...
- Supporting clients that only know GET and POST
Reference...
Hosting
Configuration
Modules
Pipeline...
- Pipeline contributors
- Well-known contributors
- PipelineContinuation members
Resources
Handlers
Binding...
- Object binders
- The default resource binder?
- ChangeSet<T> support?
Codecs...
- The Webforms Codec
- The XmlSerializer codec
- The JsonDataContract codec
- The XmlDataContract codec
Building Codecs...
- Building a media type reader
- Building a media type writer
- MediaType attribute
- Implementing configuration for ICodec
- Supporting binders and ChangeSet<> in a codec?
Using the XmlSerializerCodec
OpenRasta supports serialization of a resource using one of .NET's most familiar classes, XmlSerializer. Use this codec when you need support for attributes in your representation - for example, when rendering to support an xsd which uses XML attributes. As with "normal" usage of XmlSerializer, you will either need to mark up your resource class with appropriate attributes indicating how the resource should be serialized or implement IXmlSerializable.
Registering the codec
Whenever you want to render a resource using the XmlSerializerCodec, use the following form:
ResourceSpace.Has.ResourcesOfType<Customer>() /* your handler declaration */ .TranscodedBy<XmlSerializerCodec>(null);
When to use
The XmlSerializerCodec is slightly slower than other data contract-based codecs such as JsonDataContractCodec. However, the benefit is that you gain significant control over rendered XML. In particular, you gain support for attributes and as such this codec is a good choice when rendering to a format which has been specified in detail (e.g. has a schema).
