Example #1
0
        private static MemberInfo GetEnumValueMemberInfo(CountryEnum.Countries country)
        {
            var enumType = typeof(CountryEnum.Countries);

            var memberInfo = enumType.GetMember(enumType.GetEnumName(country));

            return(memberInfo.FirstOrDefault(m => m.DeclaringType == enumType));
        }
Example #2
0
        public static string LongCountryName(this IHtmlHelper helper, CountryEnum.Countries country)
        {
            var enumValueMemberInfo = GetEnumValueMemberInfo(country);

            var valueAttribute = enumValueMemberInfo.GetCustomAttribute(typeof(LongNameAttribute), false);

            return(valueAttribute != null?valueAttribute.ToString() : country.ToString());
        }