Skip to content

Instantly share code, notes, and snippets.

@winnicki
Created September 2, 2017 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winnicki/3e949bc56c0d72f561c9d57967b7905b to your computer and use it in GitHub Desktop.
Save winnicki/3e949bc56c0d72f561c9d57967b7905b to your computer and use it in GitHub Desktop.
readonly Lazy<DynamicContractResolver> _locationDetailsResolver =
new Lazy<DynamicContractResolver>(() =>
new DynamicContractResolver(
nameof(Models.Location.Name),
nameof(Models.Location.Address),
nameof(Models.Location.Id)));
var serializerSettings = new JsonSerializerSettings
{
ContractResolver = _locationDetailsResolver?.Value
};
var locationDetailsSerializer =
JsonSerializer
.Create(serializerSettings);
CurrentLocation =
CurrentLocationJObject?
.ToObject<Models.Location>(locationDetailsSerializer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment