private static string[] GetIndividualEnumTerms(Enum value, TermOptions termOptions) { TermAttribute termAttribute = GetEnumTermAttribute(value); bool hasTermValue = termAttribute != null && termAttribute.Values != null && termAttribute.Values.Any(); string termFormat = termOptions.GetFormatOrNull() ?? termAttribute.GetFormatOrNull() ?? GetTermSettings(value.GetType()).GetFormatOrNull() ?? null; if (hasTermValue) { return(termAttribute.Values.Select(x => FormatValue(x, termFormat, termOptions.Culture)).ToArray()); } else { TermCase termCase = termOptions.GetCaseOrNull() ?? termAttribute.GetCaseOrNull() ?? GetTermSettings(value.GetType()).GetCaseOrNull() ?? DefaultFormat; if (termFormat == null || termFormat.Contains("{0}")) { string term = termCase.ApplyTo(value.ToString()); return(new[] { FormatValue(term, termFormat, termOptions.Culture) }); } else { return(new[] { FormatValue(value, termFormat, termOptions.Culture) }); } } }
private static string[] GetIndividualEnumTerms(Enum value, TermAttribute termAttribute, ITermSettings termSettings, CultureInfo culture) { string[] values = termAttribute?.Values?.Any() ?? false ? termAttribute.Values : new[] { TermCaseResolver.ApplyCase( value.ToString(), termAttribute.GetCaseOrNull() ?? termSettings.GetCaseOrNull() ?? DefaultCase) }; string termFormat = termAttribute.GetFormatOrNull() ?? termSettings.GetFormatOrNull(); return(termFormat != null ? values.Select(x => FormatValue(x, termFormat, culture)).ToArray() : values); }