示例#1
0
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public void addToXElement(XElement node)
        {
            XNamespace ns    = Consts.XML_XEP_0004_NAMESPACE;
            XElement   xNode = new XElement(ns + "x");

            xNode.Add(new XAttribute("type", type.ToString().ToLowerInvariant()));

            // Add the XEP-0336 (Data Forms - Dynamic Forms) namespace even if we do not need it:
            xNode.Add(new XAttribute(XNamespace.Xmlns + "xdd", Consts.XML_XEP_0336_NAMESPACE));

            foreach (Field f in fields)
            {
                xNode.Add(f.toXElement(ns));
            }

            if (titel != null)
            {
                xNode.Add(new XElement("title", titel));
            }

            if (instructions != null)
            {
                xNode.Add(new XElement("instructions", instructions));
            }

            node.Add(xNode);
        }
示例#2
0
 /// <summary>
 /// Asserts the data-form is of the specified type.
 /// </summary>
 /// <param name="expected">The type to assert.</param>
 /// <exception cref="ArgumentException">The data-form is not of the
 /// expected type.</exception>
 protected void AssertType(DataFormType expected)
 {
     if (Type != expected)
     {
         throw new ArgumentException("The specified XML element is not a " +
                                     "data-form of type '" + expected.ToString() + "'.");
     }
 }
示例#3
0
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public void addToXElement(XElement node)
        {
            XNamespace ns    = Consts.XML_XEP_0004_NAMESPACE;
            XElement   xNode = new XElement(ns + "x");

            xNode.Add(new XAttribute("type", type.ToString().ToLowerInvariant()));

            foreach (Field f in FIELDS)
            {
                xNode.Add(f.toXElement(ns));
            }

            if (titel != null)
            {
                xNode.Add(new XElement("title", titel));
            }

            if (instructions != null)
            {
                xNode.Add(new XElement("instructions", instructions));
            }

            node.Add(xNode);
        }
示例#4
0
		/// <summary>
		/// Asserts the data-form is of the specified type.
		/// </summary>
		/// <param name="expected">The type to assert.</param>
		/// <exception cref="ArgumentException">The data-form is not of the
		/// expected type.</exception>
		protected void AssertType(DataFormType expected) {
			if (Type != expected) {
				throw new ArgumentException("The specified XML element is not a " +
					"data-form of type '" + expected.ToString() + "'.");
			}
		}