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
Console.WriteLine("Hello, World!"); | |
Console.ReadLine(); |
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
// Who needs XML anyway? | |
HttpConfiguration configuration = GlobalConfiguration.Configuration; | |
configuration.Formatters.Remove(configuration.Formatters.XmlFormatter); | |
configuration.Formatters.Remove(configuration.Formatters.JsonFormatter); | |
configuration.Formatters.Add(new MyJsonMediaTypeFormatter()); |
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 MyJsonMediaTypeFormatter : JsonMediaTypeFormatter | |
{ | |
public override System.Threading.Tasks.Task WriteToStreamAsync(System.Type type, object value, System.IO.Stream writeStream, System.Net.Http.HttpContent content, System.Net.TransportContext transportContext) | |
{ | |
var obj = new {d = value}; | |
return base.WriteToStreamAsync(type, obj, writeStream, content, transportContext); | |
} | |
} |