// Copyright © Selmo Technology GmbH. All Rights Reserved

using System.ComponentModel;

namespace SelmoStudio.Hmi.Server.SelmoHmi.Shared.WellKnownTypes
{
    public enum WellKnownLengthUnits
    {
        [Description("px")]
        Pixel,

        [Description("%")]
        Percentage,

        [Description("rem")]
        Rem,

        [Description("auto")]
        Auto
    }

    public static class WellKnownLengthUnitsExtensions
    {
        public static string Symbol(this WellKnownLengthUnits unit)
        {
            DescriptionAttribute[] attributes = (DescriptionAttribute[])unit.GetType().GetField(unit.ToString())
                .GetCustomAttributes(typeof(DescriptionAttribute), false);

            return attributes.Length > 0 ? attributes[0].Description : string.Empty;
        }
    }
}