/// <summary> /// Initializes a new instance of the ListField class for use in a /// requesting dataform. /// </summary> /// <param name="name">The name of the field.</param> /// <param name="required">Determines whether the field is required or /// optional.</param> /// <param name="label">A human-readable name for the field.</param> /// <param name="description">A natural-language description of the field, /// intended for presentation in a user-agent.</param> /// <param name="options">An enumerable collection of options to add to /// the field.</param> /// <param name="values">The default values of the field.</param> /// <exception cref="ArgumentNullException">The name parameter is /// null.</exception> public ListMultiField(string name, bool required = false, string label = null, string description = null, IEnumerable <Option> options = null, params string[] values) : base(DataFieldType.ListMulti, name, required, label, description) { this.values = new XmlCollection <string>(element, "value", elem => elem.InnerText); this.options = new XmlCollection <Option>(element, "option", OptionFromElement); if (options != null) { foreach (Option o in options) { Options.Add(o); } } if (values != null) { foreach (string s in values) { if (s == null) { continue; } this.values.Add(s); } } }
/// <summary> /// Initializes a new instance of the ListField class from the specified /// XML element. /// </summary> /// <param name="e">The XML 'field' element to initialize the instance /// with.</param> /// <exception cref="ArgumentNullException">The e parameter is /// null.</exception> /// <exception cref="ArgumentException">The specified XML element is not a /// valid data-field element, or the element is not a data-field of type /// 'list-multi'.</exception> internal ListMultiField(XmlElement e) : base(e) { AssertType(DataFieldType.ListMulti); this.values = new XmlCollection <string>(element, "value", elem => elem.InnerText); options = new XmlCollection <Option>(element, "option", OptionFromElement); }
public HiddenField(string name, bool required = false, string label = null, string description = null, params string[] values) : base(DataFieldType.Hidden, name, required, label, description) { this.values = new XmlCollection <string>(base.element, "value", elem => elem.InnerText); if (values != null) { foreach (string str in values) { if (str != null) { this.values.Add(str); } } } }
public ListField(string name, bool required = false, string label = null, string description = null, IEnumerable <Option> options = null, string value = null) : base(DataFieldType.ListSingle, name, required, label, description) { this.options = new XmlCollection <Option>(base.element, "option", new Func <XmlElement, Option>(this.OptionFromElement)); if (options != null) { foreach (Option option in options) { this.Options.Add(option); } } if (value != null) { this.Value = value; } }
/// <summary> /// Initializes a new instance of the JidMultiField class for use in a /// requesting dataform. /// </summary> /// <param name="name">The name of the field.</param> /// <param name="required">Determines whether the field is required or /// optional.</param> /// <param name="label">A human-readable name for the field.</param> /// <param name="description">A natural-language description of the field, /// intended for presentation in a user-agent.</param> /// <param name="values">The default values of the field.</param> /// <exception cref="ArgumentNullException">The name parameter is /// null.</exception> public JidMultiField(string name, bool required = false, string label = null, string description = null, params Jid[] values) : base(DataFieldType.TextMulti, name, required, label, description) { this.values = new XmlCollection <Jid>(element, "value", e => new Jid(element.InnerText)); if (values != null) { foreach (Jid s in values) { if (s == null) { continue; } this.values.Add(s); } } }
public JidMultiField(string name, bool required = false, string label = null, string description = null, params Jid[] values) : base(DataFieldType.TextMulti, name, required, label, description) { Func <XmlElement, Jid> conversion = null; if (conversion == null) { conversion = e => new Jid(base.element.InnerText); } this.values = new XmlCollection <Jid>(base.element, "value", conversion); if (values != null) { foreach (Jid jid in values) { if (jid != null) { this.values.Add(jid); } } } }
/// <summary> /// Initializes a new instance of the ListField class from the specified /// XML element. /// </summary> /// <param name="e">The XML 'field' element to initialize the instance /// with.</param> /// <exception cref="ArgumentNullException">The e parameter is /// null.</exception> /// <exception cref="ArgumentException">The specified XML element is not a /// valid data-field element, or the element is not a data-field of type /// 'list-single'.</exception> internal ListField(XmlElement e) : base(e) { AssertType(DataFieldType.ListSingle); options = new XmlCollection <Option>(element, "option", OptionFromElement); }
internal ListField(XmlElement e) : base(e) { base.AssertType(DataFieldType.ListSingle); this.options = new XmlCollection <Option>(base.element, "option", new Func <XmlElement, Option>(this.OptionFromElement)); }