NAnt.Core.Element.GetElementNameFromType C# (CSharp) Method

GetElementNameFromType() private static method

Returns the ElementNameAttribute.Name of the ElementNameAttribute assigned to the specified Type.
private static GetElementNameFromType ( Type type ) : string
type System.Type The of which the assigned should be retrieved.
return string
        private static string GetElementNameFromType(Type type)
        {
            if (type == null) {
                throw new ArgumentNullException("type");
            }

            ElementNameAttribute elementNameAttribute = (ElementNameAttribute)
                Attribute.GetCustomAttribute(type, typeof(ElementNameAttribute),
                false);

            if (elementNameAttribute != null) {
                return elementNameAttribute.Name;
            }

            return null;
        }