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)); }
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); }
public static bool HasAttribute <T>(AttributeNode attribute, string argumentName) where T : Attribute { return(HasAttribute <T>(attribute) && attribute.GetNamedArgument(Identifier.For(argumentName)) != null); }