public static string GetMemberName(this MemberInfo memberInfo, CosmosLinqSerializerOptions linqSerializerOptions = null) { string memberName = null; // Json.Net honors JsonPropertyAttribute more than DataMemberAttribute // So we check for JsonPropertyAttribute first. JsonPropertyAttribute jsonPropertyAttribute = memberInfo.GetCustomAttribute <JsonPropertyAttribute>(true); if (jsonPropertyAttribute != null && !string.IsNullOrEmpty(jsonPropertyAttribute.PropertyName)) { memberName = jsonPropertyAttribute.PropertyName; } else { DataContractAttribute dataContractAttribute = memberInfo.DeclaringType.GetCustomAttribute <DataContractAttribute>(true); if (dataContractAttribute != null) { DataMemberAttribute dataMemberAttribute = memberInfo.GetCustomAttribute <DataMemberAttribute>(true); if (dataMemberAttribute != null && !string.IsNullOrEmpty(dataMemberAttribute.Name)) { memberName = dataMemberAttribute.Name; } } } if (memberName == null) { memberName = memberInfo.Name; } if (linqSerializerOptions != null) { memberName = CosmosSerializationUtil.GetStringWithPropertyNamingPolicy(linqSerializerOptions, memberName); } return(memberName); }
internal MemberNames(CosmosLinqSerializerOptions options) { this.Value = CosmosSerializationUtil.GetStringWithPropertyNamingPolicy(options, nameof(this.Value)); this.HasValue = CosmosSerializationUtil.GetStringWithPropertyNamingPolicy(options, nameof(this.HasValue)); }