Exemplo n.º 1
0
        public static string GetSymbol <TEnum>(TEnum enumValue)
            where TEnum : struct, IComparable, IFormattable, IConvertible
        {
            Type t = enumValue.GetType();
            PosAndSymbolAttribute attr = t.GetField(Enum.GetName(t, enumValue)).GetCustomAttributes(typeof(PosAndSymbolAttribute), false).OfType <PosAndSymbolAttribute>().FirstOrDefault();

            return((attr == null) ? null : attr.Symbol);
        }
Exemplo n.º 2
0
        public static string GetDescription <TEnum>(TEnum enumValue, PartOfSpeech partOfSpeech)
            where TEnum : struct, IComparable, IFormattable, IConvertible
        {
            Type t = enumValue.GetType();
            PosAndSymbolAttribute attr = t.GetField(Enum.GetName(t, enumValue)).GetCustomAttributes(typeof(PosAndSymbolAttribute), false).OfType <PosAndSymbolAttribute>()
                                         .FirstOrDefault(a => a.PartOfSpeech == partOfSpeech);

            return((attr == null) ? null : attr.Description);
        }
Exemplo n.º 3
0
        public static PartOfSpeech GetPartOfSpeech <TEnum>(TEnum enumValue)
        {
            Type t = enumValue.GetType();
            PosAndSymbolAttribute attr = t.GetField(Enum.GetName(t, enumValue)).GetCustomAttributes(typeof(PosAndSymbolAttribute), false).OfType <PosAndSymbolAttribute>()
                                         .FirstOrDefault();

            if (attr == null)
            {
                return(default(PartOfSpeech));
            }

            return(attr.PartOfSpeech);
        }