Created
May 20, 2016 13:05
-
-
Save jfbueno/6bdb2ed3fa403140a7c4d01681f6bbe2 to your computer and use it in GitHub Desktop.
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 CamelCaseControllerConfigAttribute : Attribute, IControllerConfiguration | |
{ | |
public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor) | |
{ | |
var formatter = controllerSettings.Formatters.OfType<JsonMediaTypeFormatter>().Single(); | |
controllerSettings.Formatters.Remove(formatter); | |
formatter = new JsonMediaTypeFormatter | |
{ | |
SerializerSettings = { ContractResolver = new CamelCasePropertyNamesContractResolver() } | |
}; | |
controllerSettings.Formatters.Add(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
[CamelCaseControllerConfig] | |
public dynamic Get() | |
{ | |
return new | |
{ | |
Nome = "Jeferson", | |
Sobrenome = "Bueno", | |
Idade = 2000 | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment