/// <summary>Gets the name of the property for JSON serialization.</summary> /// <returns>The name.</returns> /// <exception cref="NotSupportedException">The PropertyNameHandling is not supported.</exception> public static string GetPropertyName(MemberInfo property, PropertyNameHandling propertyNameHandling) { switch (propertyNameHandling) { case PropertyNameHandling.Default: return(ReflectionCache.GetProperties(property.DeclaringType).First(p => p.MemberInfo.Name == property.Name).GetName()); case PropertyNameHandling.CamelCase: return(CamelCaseResolverLazy.Value.GetResolvedPropertyName(property.Name)); default: throw new NotSupportedException($"The PropertyNameHandling '{propertyNameHandling}' is not supported."); } }
/// <summary>Gets the name of the property for JSON serialization.</summary> /// <returns>The name.</returns> /// <exception cref="NotSupportedException">The PropertyNameHandling is not supported.</exception> public static string GetPropertyName(PropertyInfo property, PropertyNameHandling propertyNameHandling) { switch (propertyNameHandling) { case PropertyNameHandling.Default: return ReflectionCache.GetProperties(property.DeclaringType).First(p => p.PropertyInfo.Name == property.Name).GetName(); case PropertyNameHandling.CamelCase: return CamelCaseResolverLazy.Value.GetResolvedPropertyName(property.Name); default: throw new NotSupportedException($"The PropertyNameHandling '{propertyNameHandling}' is not supported."); } }