Skip to content

Implementing Configuration for a Codec

simonthorogood edited this page Dec 12, 2010 · 1 revision

Codecs (objects which implement IMediaTypeReader or IMediaTypeWriter, which both descend from ICodec) require that you implement the ICodec interface:

  object Configuration { get; set; }

This configuration object corresponds directly to the single parameter taken by the TranscodedBy<TCodec>(object configuration) method when configuring using Fluent Configuration. For example,

  ResourceSpace.Has.ResourcesOfType<Customer>()
      .AtUri("/customer/{id}")
      .HandledBy<CustomerHandler>()
      // This anonymous object is used by the WebFormsCodec to decide which view to use
      .TranscodedBy<WebFormsCodec>(new { index = "~/Views/Customer.aspx" }); 

NB: Many codecs don’t require a configuration, so this implementation will often do nothing.

See also

Clone this wiki locally