private Control CreateEnumFieldAttribute(EnumFieldAttribute enumFieldAttribute)
        {
            Control controlToAdd = new Control()
            {
                ID = enumFieldAttribute.Id
            };
            var enumType  = base.GetPropertyByFieldAttributeId(enumFieldAttribute.Id).PropertyType;
            var enumItems = Enum.GetNames(enumType).Select(enumName => new ListItem(enumName)).ToArray();

            switch (enumFieldAttribute.ControlDataType)
            {
            case ControlDataType.ListBox:
                var listBox = new ListBox();
                listBox.Items.AddRange(enumItems);
                controlToAdd = listBox;
                break;

            case ControlDataType.DropDownList:
                var dropDownList = new DropDownList();
                dropDownList.Items.AddRange(enumItems);
                controlToAdd = dropDownList;
                break;

            case ControlDataType.PageWithList:
                throw new ArgumentException($"{nameof(ControlDataType.PageWithList)} is not supported.");

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(controlToAdd);
        }
        public static Dictionary <TValue, string> GetEnumFields <TValue>(this Enum currentEnum)
        {
            var enumes = new Dictionary <TValue, string>();

            foreach (FieldInfo fi in currentEnum.GetType().GetFields().Where(t => !t.IsSpecialName))
            {
                EnumFieldAttribute da = (EnumFieldAttribute)Attribute.GetCustomAttribute(fi, typeof(EnumFieldAttribute));
                if (da != null)
                {
                    enumes.Add((TValue)fi.GetValue(currentEnum), da.DisplayName);
                }
                else
                {
                    enumes.Add((TValue)fi.GetValue(currentEnum), fi.Name);
                }
            }
            return(enumes);
        }