using Netina.Common.Models.Entity;

namespace Netina.Common.Extensions
{
    public static class ClassDisplayExtensions
    {
        public static string GetDisplayAttributeName<T>()
        {
            var attrs =
                Attribute.GetCustomAttributes(typeof(T));

            foreach (var attr in attrs)
            {
                var displayAttribute = attr as PageClassDisplay;
                if (displayAttribute == null)
                    continue;
                return displayAttribute.GetName();
            }

            return null;
        }

        public static string GetDisplayAttributeDescription<T>()
        {
            var attrs =
                Attribute.GetCustomAttributes(typeof(T));

            foreach (var attr in attrs)
            {
                var displayAttribute = attr as PageClassDisplay;
                if (displayAttribute == null)
                    continue;
                return displayAttribute.GetDescription();
            }

            return null;
        }
    }
}