예제 #1
0
 private static InformationAttribute GetAttribute(Type type)
 {
     InformationAttribute[] attributes = (InformationAttribute[])type.GetCustomAttributes(typeof(InformationAttribute), false);
     if (attributes.Length == 1)
     {
         InformationAttribute attrib = attributes[0];
         return(attrib);
     }
     return(null);
 }
예제 #2
0
        /// <summary>
        /// Returns the tag of the given type, or nothing if no <see cref="InformationAttribute"/> was specified.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static object GetTag(Type type)
        {
            Assertions.AssertNotNull(type, "type");

            InformationAttribute attribute = GetAttribute(type);

            if (attribute != null)
            {
                return(attribute.Tag);
            }

            return(String.Empty);
        }
예제 #3
0
        /// <summary>
        /// Returns the description of the given type, or nothing if no <see cref="InformationAttribute"/> was specified.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string GetDescription(Type type)
        {
            Assertions.AssertNotNull(type, "type");

            InformationAttribute attribute = GetAttribute(type);

            if (attribute != null)
            {
                string res = type.GetResourceString(attribute.Description);
                return(res ?? attribute.Description);
            }

            return(String.Empty);
        }
예제 #4
0
        /// <summary>
        /// Returns the display name of the given type, or the type name itself if no <see cref="InformationAttribute"/> was specified.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string GetDisplayName(Type type)
        {
            Assertions.AssertNotNull(type, "type");

            InformationAttribute attribute = GetAttribute(type);

            if (attribute != null)
            {
                string res = type.GetResourceString(attribute.DisplayName);
                return(res ?? attribute.DisplayName);
            }

            return(type.Name);
        }