Пример #1
0
        private static int GetPrecedence <TOp>(TOp op)
            where TOp : struct
        {
            var attribute = EnumAttributesCache <OperatorPrecedenceAttribute> .GetAttribute(op);

            return(attribute.Precedence);
        }
Пример #2
0
        private void RegisterOperators <TEnum>() where TEnum : struct
        {
            foreach (var value in Enum.GetValues(typeof(TEnum)).Cast <TEnum>())
            {
                var precedence = EnumAttributesCache <OperatorPrecedenceAttribute> .GetAttribute(value).Precedence;

                var opSymbols = EnumAttributesCache <OperatorSynonymsAttribute> .GetAttribute(value).Synonyms;

                RegisterOperators(precedence, opSymbols);
            }
        }
Пример #3
0
 public static string OfEnum <T>(T enumValue)
     where T : struct
 {
     return(EnumAttributesCache <SynonymAttribute> .GetAttribute(enumValue).Value);
 }
Пример #4
0
 public static string OfEnumUnsafe(object enumValue)
 {
     return(EnumAttributesCache <SynonymAttribute> .GetAttributeUnsafe(enumValue).Value);
 }