コード例 #1
0
        /// <summary>
        /// Gets the descriptions for all values in an enum
        /// </summary>
        /// <typeparam name="T">The enum type</typeparam>
        /// <returns>The list of descriptions</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  05/09/13 RCG 2.80.28 N/A    Created

        public static IEnumerable <string> GetValueDescriptions <T>()
        {
            List <string>   Descriptions = new List <string>();
            IEnumerable <T> Values       = GetValues <T>();

            foreach (T CurrentValue in Values)
            {
                Enum EnumValue = (Enum)(object)CurrentValue;

                Descriptions.Add(EnumDescriptionRetriever.RetrieveDescription(EnumValue));
            }

            return(Descriptions);
        }
コード例 #2
0
ファイル: EnumExtensions.cs プロジェクト: lenloe1/Stuff
        /// <summary>
        /// Parses a string into an enum value.
        /// </summary>
        /// <typeparam name="T">The enum type.</typeparam>
        /// <param name="strValue">The description of the enum value to parse.</param>
        /// <returns>The enum value.</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------------
        //  04/28/09 RCG 2.20.03        Created

        public static T ParseToEnum <T>(this string strValue)
        {
            return(EnumDescriptionRetriever.ParseToEnum <T>(strValue));
        }
コード例 #3
0
ファイル: EnumExtensions.cs プロジェクト: lenloe1/Stuff
        /// <summary>
        /// Extension method for enumerations that will return the description specified using a DescriptionAttribute modifier.
        /// </summary>
        /// <param name="value">The enumeration value.</param>
        /// <returns>The description of the value.</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------------
        //  04/28/09 RCG 2.20.03        Created

        public static string ToDescription(this Enum value)
        {
            return(EnumDescriptionRetriever.RetrieveDescription(value));
        }