UniAlltid.Language.API.Areas.HelpPage.ModelDescriptions.ModelDescriptionGenerator.GetMemberName C# (CSharp) Method

GetMemberName() private static method

private static GetMemberName ( MemberInfo member, bool hasDataContractAttribute ) : string
member System.Reflection.MemberInfo
hasDataContractAttribute bool
return string
        private static string GetMemberName(MemberInfo member, bool hasDataContractAttribute)
        {
            JsonPropertyAttribute jsonProperty = member.GetCustomAttribute<JsonPropertyAttribute>();
            if (jsonProperty != null && !String.IsNullOrEmpty(jsonProperty.PropertyName))
            {
                return jsonProperty.PropertyName;
            }

            if (hasDataContractAttribute)
            {
                DataMemberAttribute dataMember = member.GetCustomAttribute<DataMemberAttribute>();
                if (dataMember != null && !String.IsNullOrEmpty(dataMember.Name))
                {
                    return dataMember.Name;
                }
            }

            return member.Name;
        }