public MultipleChoiceOption(string key, IOptionValue <T> value, T[] choices, Func <T, string> translateFunction) { m_key = key; m_value = value; m_choices = choices; m_translateFunction = translateFunction; }
internal SqlFlagListOptionBehaviour(IOptionValue optionValue, string query, string valueMember = "value", string displayMember = "displayValue") : base(optionValue) { Query = query ?? throw new ArgumentNullException(nameof(query)); ValueMember = valueMember; DisplayMember = displayMember; }
internal SqlFixedListOptionBehaviour(IOptionValue optionValue, string query, string valueMember, string displayMember) : base(optionValue) { Query = query ?? throw new ArgumentNullException(nameof(query)); ValueMember = valueMember ?? throw new ArgumentNullException(nameof(valueMember)); DisplayMember = displayMember ?? throw new ArgumentNullException(nameof(displayMember)); }
internal MultiListOptionBehaviour(IOptionValue optionValue, IEnumerable <ListItem> validItems, bool sorted = false, string separator = ";") : base(optionValue) { ListItems = new List <ListItem>(validItems); Sorted = sorted; Separator = separator; }
internal RangedOptionBehaviour(IOptionValue optionValue, string minValue, string maxValue) : base(optionValue) { IsMinValueExists = true; MinValue = minValue ?? throw new ArgumentNullException(nameof(minValue)); IsMaxValueExists = true; MaxValue = maxValue ?? throw new ArgumentNullException(nameof(maxValue)); }
public RangedOptionBehaviour(IOptionValue optionValue, string minValue, string maxValue) : base(optionValue) { IsMinValueExists = true; MinValue = minValue; IsMaxValueExists = true; MaxValue = maxValue; }
public CycleOption(string key, IOptionValue <int> value, int minimum, int maximum, int step = 1) { m_key = key; m_value = value; m_minimum = minimum; m_maximum = maximum; m_step = step; }
internal SqlMultiListOptionBehaviour(IOptionValue optionValue, string query, bool sorted = false, string separator = ";", string valueMember = "value", string displayMember = "displayValue") : base(optionValue) { Sorted = sorted; Separator = separator; Query = query ?? throw new ArgumentNullException(nameof(query)); ValueMember = valueMember; DisplayMember = displayMember; }
internal SqlMultiListOptionBehaviour(IOptionValue optionValue, string query, bool sorted, string separator, string valueMember, string displayMember) : base(optionValue) { Sorted = sorted; Separator = separator ?? throw new ArgumentNullException(nameof(separator)); Query = query ?? throw new ArgumentNullException(nameof(query)); ValueMember = valueMember ?? throw new ArgumentNullException(nameof(valueMember)); DisplayMember = displayMember ?? throw new ArgumentNullException(nameof(displayMember)); }
internal FixedListOptionBehaviour(IOptionValue optionValue, IEnumerable <ListItem> listItems) : base(optionValue) { if (listItems == null) { throw new ArgumentNullException(nameof(listItems)); } ListItems = new List <ListItem>(listItems); }
private Func <XElement> CreateFlagListBehaviour(IOptionValue optionValue, IEnumerable <ListItem> list) { var flagList = new XElement("flagList"); foreach (var listItem in list) { flagList.Add(new XElement("listItem", new XAttribute("value", listItem.Value.ToString()), new XAttribute("displayValue", listItem.DisplayValue))); } return(() => flagList); }
private Func <XElement> CreateMultiListBehaviour(IOptionValue optionValue, IEnumerable <ListItem> list, bool sorted = false, string separator = ";") { var multiList = new XElement("multiList", new XAttribute("sorted", sorted), new XAttribute("separator", optionValue.GetStringValue(separator))); foreach (var listItem in list) { multiList.Add(new XElement("listItem", new XAttribute("value", listItem.Value.ToString()), new XAttribute("displayValue", listItem.DisplayValue))); } return(() => multiList); }
internal MultiListOptionBehaviour(IOptionValue optionValue, IEnumerable <ListItem> listItems, bool sorted = false, string separator = ";") : base(optionValue) { // ReSharper disable once PossibleMultipleEnumeration Validate.NotNull(listItems, nameof(listItems)); Validate.NotNull(separator, nameof(separator)); // ReSharper disable once PossibleMultipleEnumeration ListItems = new List <ListItem>(listItems); Sorted = sorted; Separator = separator; }
private OptionBehaviour CreateBehaviour(XElement root, IOptionValue optionValue) { var elements = root.Elements(); foreach (var element in elements) { if (TryCreateBehaviour(element, optionValue, out var optionBehaviour)) { return(optionBehaviour); } } return(new SimpleOptionBehaviour(optionValue)); }
private List <ListItem> CreateBehaviourList(XElement root, IOptionValue optionValue) { var elements = root.Elements(); var list = new List <ListItem>(); foreach (var element in elements) { if (element.Name.LocalName == FixedListElement.ListItemElement.ElementName) { var value = optionValue.GetValue(element.GetAttributeValue <string>(FixedListElement.ListItemElement.Attrs.Value)); string displayValue = element.GetAttributeValue <string>(FixedListElement.ListItemElement.Attrs.DisplayValue); list.Add(new ListItem(value, displayValue)); } } return(list); }
/// <summary> /// Creates the option value view model. /// </summary> /// <param name="option">The option.</param> /// <returns>Created option value view model</returns> private OptionValueViewModel CreateOptionValueViewModel(IOptionValue option) { var optionViewModel = new OptionValueViewModel { Type = option.Type, OptionKey = option.Key.Trim(), OptionValue = option.Value, CustomOption = option.CustomOption != null ? new CustomOptionViewModel { Identifier = option.CustomOption.Identifier, Title = option.CustomOption.Title, Id = option.CustomOption.Id } : null, }; return(optionViewModel); }
public RangedOptionBehaviour(IOptionValue optionValue, string value, bool isMin) : base(optionValue) { if (isMin) { IsMinValueExists = true; MinValue = value; IsMaxValueExists = false; MaxValue = null; } else { IsMinValueExists = false; MinValue = null; IsMaxValueExists = true; MaxValue = value; } }
private Func <XElement> CreateRangedBehaviourMinMax(IOptionValue optionValue, string minValue, string maxValue, object isMin = null) { if (isMin == null) { return(() => new XElement("rangedMinMax", new XAttribute("min", optionValue.GetStringValue(minValue)), new XAttribute("max", optionValue.GetStringValue(maxValue)))); } else if ((bool)isMin) { return(() => new XElement("rangedMin", new XAttribute("min", optionValue.GetStringValue(minValue)))); } else if (!(bool)isMin) { return(() => new XElement("rangedMax", new XAttribute("max", optionValue.GetStringValue(maxValue)))); } else { return(null); } }
internal RangedOptionBehaviour(IOptionValue optionValue, string value, bool isMin) : base(optionValue) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (isMin) { IsMinValueExists = true; MinValue = value; IsMaxValueExists = false; MaxValue = null; } else { IsMinValueExists = false; MinValue = null; IsMaxValueExists = true; MaxValue = value; } }
protected OptionBehaviour(IOptionValue optionValue) { Validate.NotNull(optionValue, nameof(optionValue)); OptionValue = optionValue; }
internal void AddOption(IOptionValue opt) { options.Add(opt); }
internal FixedListOptionBehaviour(IOptionValue optionValue, IEnumerable <ListItem> validItems) : base(optionValue) { ListItems = new List <ListItem>(validItems); }
private bool TryCreateBehaviour(XElement root, IOptionValue optionValue, out OptionBehaviour optionBehaviour) { string name = root.Name.LocalName; optionBehaviour = null; switch (name) { case "rangedMinMax": { string min = root.GetAttributeValue <string>("min"); string max = root.GetAttributeValue <string>("max"); optionBehaviour = new RangedOptionBehaviour(optionValue, min, max); } break; case "rangedMax": { string max = root.GetAttributeValue <string>("max"); optionBehaviour = new RangedOptionBehaviour(optionValue, max, false); } break; case "rangedMin": { string min = root.GetAttributeValue <string>("min"); optionBehaviour = new RangedOptionBehaviour(optionValue, min, true); } break; case "fixedList": optionBehaviour = CreateFixedListBehaviour(root, optionValue); break; case "flagList": optionBehaviour = CreateFlagListBehaviour(root, optionValue); break; case "multiList": { bool sorted = root.GetAttributeValue <bool>("sorted"); string separator = root.GetAttributeValue <string>("separator"); optionBehaviour = CreateMultiListBehaviour(root, optionValue, sorted, separator); } break; case "sqlFixedList": { string query = root.GetAttributeValue <string>("query"); string valueFieldName = root.GetAttributeValue <string>("valueFieldName"); string displayValueFieldName = root.GetAttributeValue <string>("displayValueFieldName"); optionBehaviour = new SqlFixedListOptionBehaviour(optionValue, query, valueFieldName, displayValueFieldName); } break; case "sqlFlagList": { string query = root.GetAttributeValue <string>("query"); string valueFieldName = root.GetAttributeValue <string>("valueFieldName"); string displayValueFieldName = root.GetAttributeValue <string>("displayValueFieldName"); optionBehaviour = new SqlFlagListOptionBehaviour(optionValue, query, valueFieldName, displayValueFieldName); } break; case "sqlMultiList": { string query = root.GetAttributeValue <string>("query"); bool sorted = root.GetAttributeValue <bool>("sorted"); string separator = root.GetAttributeValue <string>("separator"); string valueFieldName = root.GetAttributeValue <string>("valueFieldName"); string displayValueFieldName = root.GetAttributeValue <string>("displayValueFieldName"); optionBehaviour = new SqlMultiListOptionBehaviour(optionValue, query, sorted, separator, valueFieldName, displayValueFieldName); } break; } return(optionBehaviour != null); }
public ToggleOption(string key, IOptionValue <bool> value) { m_key = key; m_value = value; }
private MultiListOptionBehaviour CreateMultiListBehaviour(XElement root, IOptionValue optionValue, bool sorted, string separator) { var list = CreateBehaviourList(root, optionValue); return(new MultiListOptionBehaviour(optionValue, list, sorted, separator)); }
private FlagListOptionBehaviour CreateFlagListBehaviour(XElement root, IOptionValue optionValue) { var list = CreateBehaviourList(root, optionValue); return(new FlagListOptionBehaviour(optionValue, list)); }
protected OptionBehaviour(IOptionValue optionValue) { OptionValue = optionValue ?? throw new ArgumentNullException(nameof(optionValue)); }
private bool TryCreateBehaviour(XElement root, IOptionValue optionValue, out OptionBehaviour optionBehaviour) { string name = root.Name.LocalName; optionBehaviour = null; switch (name) { case RangedMinMaxElement.ElementName: { string min = ReplaceConstants <string>(root, RangedMinMaxElement.Attrs.Min); string max = ReplaceConstants <string>(root, RangedMinMaxElement.Attrs.Max); optionBehaviour = new RangedOptionBehaviour(optionValue, min, max); } break; case RangedMaxElement.ElementName: { string max = ReplaceConstants <string>(root, RangedMaxElement.Attrs.Max); optionBehaviour = new RangedOptionBehaviour(optionValue, max, false); } break; case RangedMinElement.ElementName: { string min = ReplaceConstants <string>(root, RangedMinElement.Attrs.Min); optionBehaviour = new RangedOptionBehaviour(optionValue, min, true); } break; case FixedListElement.ElementName: optionBehaviour = CreateFixedListBehaviour(root, optionValue); break; case FlagListElement.ElementName: optionBehaviour = CreateFlagListBehaviour(root, optionValue); break; case MultiListElement.ElementName: { bool sorted = DataConversion.Convert <bool>(ReplaceConstants(root.TryGetAttributeValue(MultiListElement.Attrs.Sorted, MultiListElement.Attrs.Defaults.Sorted).ToString())); string separator = ReplaceConstants(root.TryGetAttributeValue(MultiListElement.Attrs.Separator, MultiListElement.Attrs.Defaults.Separator)); optionBehaviour = CreateMultiListBehaviour(root, optionValue, sorted, separator); } break; case SqlFixedListElement.ElementName: { string query = ReplaceConstants <string>(root, SqlFixedListElement.Attrs.Query); string valueFieldName = ReplaceConstants(root.TryGetAttributeValue(SqlFixedListElement.Attrs.ValueFieldName, SqlFixedListElement.Attrs.Defaults.ValueFieldName)); string displayValueFieldName = ReplaceConstants(root.TryGetAttributeValue(SqlFixedListElement.Attrs.DisplayValueFieldName, SqlFixedListElement.Attrs.Defaults.DisplayValueFieldName)); optionBehaviour = new SqlFixedListOptionBehaviour(optionValue, query, valueFieldName, displayValueFieldName); } break; case SqlFlagListElement.ElementName: { string query = ReplaceConstants <string>(root, SqlFlagListElement.Attrs.Query); string valueFieldName = ReplaceConstants(root.TryGetAttributeValue(SqlFlagListElement.Attrs.ValueFieldName, SqlFlagListElement.Attrs.Defaults.ValueFieldName)); string displayValueFieldName = ReplaceConstants(root.TryGetAttributeValue(SqlFlagListElement.Attrs.DisplayValueFieldName, SqlFlagListElement.Attrs.Defaults.DisplayValueFieldName)); optionBehaviour = new SqlFlagListOptionBehaviour(optionValue, query, valueFieldName, displayValueFieldName); } break; case SqlMultiListElement.ElementName: { string query = ReplaceConstants <string>(root, SqlMultiListElement.Attrs.Query); bool sorted = DataConversion.Convert <bool>(ReplaceConstants(root.TryGetAttributeValue(SqlMultiListElement.Attrs.Sorted, SqlMultiListElement.Attrs.Defaults.Sorted).ToString())); string separator = ReplaceConstants(root.TryGetAttributeValue(SqlMultiListElement.Attrs.Separator, SqlMultiListElement.Attrs.Defaults.Separator)); string valueFieldName = ReplaceConstants(root.TryGetAttributeValue(SqlMultiListElement.Attrs.ValueFieldName, SqlMultiListElement.Attrs.Defaults.ValueFieldName)); string displayValueFieldName = ReplaceConstants(root.TryGetAttributeValue(SqlMultiListElement.Attrs.DisplayValueFieldName, SqlMultiListElement.Attrs.Defaults.DisplayValueFieldName)); optionBehaviour = new SqlMultiListOptionBehaviour(optionValue, query, sorted, separator, valueFieldName, displayValueFieldName); } break; } return(optionBehaviour != null); }
public SimpleOptionBehaviour(IOptionValue optionValue) : base(optionValue) { }
public OptionBehaviourTest(IOptionValue optionValue) : base(optionValue) { }