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) }); } } }
public string TermCase(TermCase termCase, string value) { return(termCase.ApplyTo(value)); }