public void SetUp() { testBench = new Page(); intEditable = new EditableEnumAttribute("Integer", 0, typeof(enumDays)) { Name = "DaysInteger" }; stringEditable = new EditableEnumAttribute("String", 1, typeof(enumDays)) { Name = "DaysString" }; enumEditable = new EditableEnumAttribute("Enum", 2, typeof(enumDays)) { Name = "DaysEnum" }; intEditor = (DropDownList)intEditable.AddTo(testBench); stringEditor = (DropDownList)stringEditable.AddTo(testBench); enumEditor = (DropDownList)enumEditable.AddTo(testBench); item = new EnumableItem(); item.DaysEnum = enumDays.Mon; item.DaysInteger = 1; item.DaysString = "Mon"; }
/// <summary> /// Adds an <see cref="EditableEnumAttribute"/> to the item definition. /// </summary> /// <param name="itemDefinition">Specifies the <see cref="ItemDefinition"/> the /// <see cref="EditableEnumAttribute"/> will be added to.</param> /// <param name="title">Specifies the value to use for /// <see cref="EditableEnumAttribute.Title"/>.</param> /// <param name="sortOrder">Specifies the value to use for /// <see cref="EditableEnumAttribute.SortOrder"/>.</param> /// <param name="enumType">Specifies the value type of enum.</param> /// <param name="containerName">Specifies the value to use for /// <see cref="EditableEnumAttribute.ContainerName"/>.</param> /// <param name="propertyKey">Specifies the value to use for /// <see cref="EditableEnumAttribute.Name"/>.</param> /// <param name="helpTitle">Specifies the value to use for /// <see cref="EditableEnumAttribute.HelpTitle"/>.</param> /// <param name="helpText">Specifies the value to use for /// <see cref="EditableEnumAttribute.HelpText"/>.</param> /// <returns>The <see cref="EditableEnumAttribute"/> added to the item definition.</returns> public static EditableEnumAttribute AddEditableEnum(this ItemDefinition itemDefinition, string title, int sortOrder, Type enumType, string containerName, string propertyKey, string helpTitle = null, string helpText = null) { if (itemDefinition == null) throw new ArgumentNullException("itemDefinition", "itemDefinition is null."); if (String.IsNullOrEmpty(title)) throw new ArgumentException("title is null or empty.", "title"); if (enumType == null) throw new ArgumentNullException("enumType", "enumType is null."); if (String.IsNullOrEmpty(containerName)) throw new ArgumentException("containerName is null or empty.", "containerName"); if (String.IsNullOrEmpty(propertyKey)) throw new ArgumentException("propertyKey is null or empty.", "propertyKey"); EditableEnumAttribute result = new EditableEnumAttribute(title, sortOrder, enumType) { ContainerName = containerName, Name = propertyKey, HelpTitle = helpTitle, HelpText = helpText }; itemDefinition.Add(result); Debug.WriteLine(string.Format("{0} property added to {1}", propertyKey, itemDefinition.Title)); return result; }