demo.sinch.com.Areas.HelpPage.ModelDescriptions.ModelDescriptionGenerator.ShouldDisplayMember C# (CSharp) Method

ShouldDisplayMember() private static method

private static ShouldDisplayMember ( MemberInfo member, bool hasDataContractAttribute ) : bool
member System.Reflection.MemberInfo
hasDataContractAttribute bool
return bool
        private static bool ShouldDisplayMember(MemberInfo member, bool hasDataContractAttribute) {
            var jsonIgnore = member.GetCustomAttribute<JsonIgnoreAttribute>();
            var xmlIgnore = member.GetCustomAttribute<XmlIgnoreAttribute>();
            var ignoreDataMember = member.GetCustomAttribute<IgnoreDataMemberAttribute>();
            var nonSerialized = member.GetCustomAttribute<NonSerializedAttribute>();
            var apiExplorerSetting = member.GetCustomAttribute<ApiExplorerSettingsAttribute>();

            var hasMemberAttribute = member.DeclaringType.IsEnum
                ? member.GetCustomAttribute<EnumMemberAttribute>() != null
                : member.GetCustomAttribute<DataMemberAttribute>() != null;

            // Display member only if all the followings are true:
            // no JsonIgnoreAttribute
            // no XmlIgnoreAttribute
            // no IgnoreDataMemberAttribute
            // no NonSerializedAttribute
            // no ApiExplorerSettingsAttribute with IgnoreApi set to true
            // no DataContractAttribute without DataMemberAttribute or EnumMemberAttribute
            return jsonIgnore == null &&
                   xmlIgnore == null &&
                   ignoreDataMember == null &&
                   nonSerialized == null &&
                   (apiExplorerSetting == null || !apiExplorerSetting.IgnoreApi) &&
                   (!hasDataContractAttribute || hasMemberAttribute);
        }