Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="enumValue"></param>
        /// <returns></returns>
        public static string GetDescription(this Enum enumValue)
        {
            if (enumValue == null)
            {
                throw new System.ArgumentNullException("enumValue", "enumValue== null");
            }

            var enumType = enumValue.GetType();

            var descriptions = GetEnumDescriptions(enumType);

            if (descriptions != null && descriptions.Length > 0)
            {
                foreach (var item in descriptions)
                {
                    if (enumValue.Equals(item.OriginalValue))
                    {
                        return(StringFormatter.Format(item.Description));
                    }
                }
            }
            return(enumValue.ToString());
        }
Beispiel #2
0
 /// <summary>
 /// 通过资源名称得到对应的资源值
 /// </summary>
 /// <param name="resourceName"></param>
 /// <returns></returns>
 public static string StringResource(this string resourceName)
 {
     return(StringFormatter.Format("${res:" + resourceName + "}"));
 }