Created
January 8, 2012 02:36
-
-
Save glennblock/1576925 to your computer and use it in GitHub Desktop.
Web Api - Order formatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrderMediaTypeFormatterJson : MediaTypeFormatter | |
{ | |
public OrderMediaTypeFormatter() { | |
SupportedMediaTypes.Add( | |
new MediaTypeHeaderValue("application/contoso.orders+json") | |
); | |
} | |
public override object OnWriteToStream(Type type, object value, System.IO.Stream stream, HttpContentHeaders contentHeaders, System.Net.TransportContext context) | |
{ | |
var linkedOrder = value as ILinkable<Order>(); | |
dynamic json = new JsonObject() | |
//write the order to json | |
} | |
public void OnReadFromStream(Type type, System.IO.Stream stream, HttpContentHeaders contentHeaders) { | |
throw new NotImplementedException(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment