/// <summary>Gets the name of the property for JSON serialization.</summary> /// <returns>The name.</returns> internal static string GetName(this ContextualAccessorInfo accessorInfo) { if (!_names.ContainsKey(accessorInfo)) { lock (_names) { if (!_names.ContainsKey(accessorInfo)) { _names[accessorInfo] = GetNameWithoutCache(accessorInfo); } } } return(_names[accessorInfo]); }
/// <summary>Gets the description of the given member (based on the DescriptionAttribute, DisplayAttribute or XML Documentation).</summary> /// <param name="accessorInfo">The accessor info.</param> /// <returns>The description or null if no description is available.</returns> public static string GetDescription(this ContextualAccessorInfo accessorInfo) { var description = GetDescription(accessorInfo.AccessorType.Attributes); if (description != null) { return(description); } var summary = accessorInfo.MemberInfo.GetXmlDocsSummary(); if (summary != string.Empty) { return(summary); } return(null); }
/// <summary>Gets the description of the given member (based on the DescriptionAttribute, DisplayAttribute or XML Documentation).</summary> /// <param name="accessorInfo">The accessor info.</param> /// <param name="xmlDocsSettings">The XML Docs settings.</param> /// <returns>The description or null if no description is available.</returns> public static string GetDescription(this ContextualAccessorInfo accessorInfo, IXmlDocsSettings xmlDocsSettings) { var description = GetDescription(accessorInfo.AccessorType.Attributes); if (description != null) { return(description); } if (xmlDocsSettings.UseXmlDocumentation) { var summary = accessorInfo.MemberInfo.GetXmlDocsSummary(xmlDocsSettings.ResolveExternalXmlDocumentation); if (summary != string.Empty) { return(summary); } } return(null); }
private static string GetNameWithoutCache(ContextualAccessorInfo accessorInfo) { var jsonPropertyAttribute = accessorInfo.AccessorType.GetContextAttribute <JsonPropertyAttribute>(); if (jsonPropertyAttribute != null && !string.IsNullOrEmpty(jsonPropertyAttribute.PropertyName)) { return(jsonPropertyAttribute.PropertyName); } var dataMemberAttribute = accessorInfo.AccessorType.GetContextAttribute <DataMemberAttribute>(); if (dataMemberAttribute != null && !string.IsNullOrEmpty(dataMemberAttribute.Name)) { var dataContractAttribute = accessorInfo.MemberInfo.DeclaringType.ToCachedType().GetInheritedAttribute <DataContractAttribute>(); if (dataContractAttribute != null) { return(dataMemberAttribute.Name); } } return(accessorInfo.Name); }