Example #1
0
		/// <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.InnerText);
			if (values != null) {
				foreach (string s in values) {
					if (s == null)
						continue;
					this.values.Add(s);
				}
			}
		}
Example #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="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;
		}
Example #3
0
 /// <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);
         }
     }
 }
Example #4
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.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);
				}
			}
		}
Example #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-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);
		}
Example #6
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(XmlElement e)
     : base(e)
 {
     AssertType(DataFieldType.ListSingle);
     options = new XmlCollection<Option>(Element, "option", OptionFromElement);
 }