Exemple #1
0
        public static T GetAttributeValue <T>(AttributeNode attribute, string argumentName)
        {
            if (attribute == null || string.IsNullOrEmpty(argumentName))
            {
                return(default(T));
            }

            Literal argument = attribute.GetNamedArgument(Identifier.For(argumentName)) as Literal;

            if (argument != null)
            {
                return((T)argument.Value);
            }

            return(default(T));
        }
Exemple #2
0
        public static bool TryGetAttributeValue <T>(AttributeNode attribute, string argumentName, out T value)
        {
            value = default(T);

            if (attribute == null ||
                string.IsNullOrEmpty(argumentName))
            {
                return(false);
            }

            Literal argument = attribute.GetNamedArgument(Identifier.For(argumentName)) as Literal;

            if (argument != null)
            {
                value = (T)argument.Value;
                return(true);
            }

            return(false);
        }
Exemple #3
0
 public static bool HasAttribute <T>(AttributeNode attribute, string argumentName) where T : Attribute
 {
     return(HasAttribute <T>(attribute) &&
            attribute.GetNamedArgument(Identifier.For(argumentName)) != null);
 }