示例#1
0
 /// <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(XElement e)
     : base(e)
 {
     AssertType(DataFieldType.ListMulti);
     this.values = new XmlCollection <string>(element, "value", elem => elem.Value);
     options     = new XmlCollection <Option>(element, "option", OptionFromElement);
 }
示例#2
0
 /// <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.Value);
     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);
         }
     }
 }
示例#3
0
 /// <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="value">The default value of the field.</param>
 /// <exception cref="ArgumentNullException">The name parameter is
 /// null.</exception>
 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>(element, "option", OptionFromElement);
     if (options != null)
     {
         foreach (Option o in options)
         {
             Options.Add(o);
         }
     }
     if (value != null)
     {
         Value = value;
     }
 }
 /// <summary>
 /// Initializes a new instance of the TextMultiField 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 TextMultiField(string name, bool required = false, string label = null,
                       string description         = null, params string[] values)
     : base(DataFieldType.TextMulti, name, required, label, description)
 {
     this.values = new XmlCollection <string>(element, "value", elem => elem.Value);
     if (values != null)
     {
         foreach (string s in values)
         {
             if (s == null)
             {
                 continue;
             }
             this.values.Add(s);
         }
     }
 }
示例#5
0
 /// <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(XElement e)
     : base(e)
 {
     AssertType(DataFieldType.ListSingle);
     options = new XmlCollection <Option>(element, "option", OptionFromElement);
 }