Exemple #1
0
		/// <summary>
		/// Allow to use the Name of enum value
		/// </summary>
		public static string GetEnumName(System.Type value, string description)
		{
			FieldInfo[] fis = value.GetFields();
			foreach (FieldInfo fi in fis)
			{
				DescriptionAttribute[] attributes =
				  (DescriptionAttribute[])fi.GetCustomAttributes
				  (typeof(DescriptionAttribute), false);
				if (attributes.Length > 0)
				{
					if (attributes[0].Description == description)
					{
						return fi.Name;
					}
				}
			}
			return description;
		}