Does Json.NET cache types’ serialization information?

Yes, it does. Json.NET caches type serialization information inside its IContractResolver classes DefaultContractResolver and CamelCasePropertyNamesContractResolver. Unless you specify a custom contract resolver, this information is cached and reused. For DefaultContractResolver a global static instance is maintained internally that Json.NET uses whenever the application does not specify its own contract resolver. CamelCasePropertyNamesContractResolver, on the other hand, … Read more

Retrieving Property name from lambda expression

I recently did a very similar thing to make a type safe OnPropertyChanged method. Here’s a method that’ll return the PropertyInfo object for the expression. It throws an exception if the expression is not a property. public PropertyInfo GetPropertyInfo<TSource, TProperty>( TSource source, Expression<Func<TSource, TProperty>> propertyLambda) { Type type = typeof(TSource); MemberExpression member = propertyLambda.Body as … Read more