using System;
using System.ComponentModel;
using System.Linq;
using System.Reflection;

namespace LeafWeb.Core.Utility
{
	public static class ReflectionExtensions
	{
	    public static string GetDescription(this Enum value)
	    {
	        return
	            value
	                .GetType()
	                .GetMember(value.ToString())
	                .FirstOrDefault()
	                ?.GetCustomAttribute<DescriptionAttribute>()
	                ?.Description;
	    }
	}
}