示例#1
0
        /// <summary>
        /// Deserialzes from ajax XML.
        /// </summary>
        /// <param name="n">The n.</param>
        /// <returns></returns>
        internal static IJavaScriptObject DeserialzeFromAjaxXml(XmlNode n)
        {
            switch (n.Name)
            {
            case "array":

                JavaScriptArray a = new JavaScriptArray();

                foreach (XmlNode item in n.ChildNodes)
                {
                    a.Add(DeserialzeFromAjaxXml(item));
                }

                return(a);

            case "boolean":

                JavaScriptBoolean b = new JavaScriptBoolean(n.InnerText == "true");
                return(b);

            case "number":

                JavaScriptNumber i = new JavaScriptNumber();
                i.Append(n.InnerText);

                return(i);

            case "string":

                JavaScriptString s = new JavaScriptString();
                s.Append(n.InnerText);

                return(s);

            case "object":

                JavaScriptObject o = new JavaScriptObject();

                foreach (XmlNode p in n.SelectNodes("property"))
                {
                    if (p.Attributes["name"] == null || p.ChildNodes.Count != 1)
                    {
                        continue;
                    }

                    o.Add(p.Attributes["name"].Value, DeserialzeFromAjaxXml(p.ChildNodes[0]));
                }

                return(o);
            }

            return(null);
        }
		/// <summary>
		/// Deserialzes from ajax XML.
		/// </summary>
		/// <param name="n">The n.</param>
		/// <returns></returns>
		internal static IJavaScriptObject DeserialzeFromAjaxXml(XmlNode n)
		{
			switch (n.Name)
			{
				case "array":

					JavaScriptArray a = new JavaScriptArray();

					foreach (XmlNode item in n.ChildNodes)
						a.Add(DeserialzeFromAjaxXml(item));

					return a;

				case "boolean":

					JavaScriptBoolean b = new JavaScriptBoolean(n.InnerText == "true");
					return b;

				case "number":

					JavaScriptNumber i = new JavaScriptNumber();
					i.Append(n.InnerText);

					return i;

				case "string":

					JavaScriptString s = new JavaScriptString();
					s.Append(n.InnerText);

					return s;

				case "object":

					JavaScriptObject o = new JavaScriptObject();

					foreach (XmlNode p in n.SelectNodes("property"))
					{
						if (p.Attributes["name"] == null || p.ChildNodes.Count != 1)
							continue;

						o.Add(p.Attributes["name"].Value, DeserialzeFromAjaxXml(p.ChildNodes[0]));
					}

					return o;
			}

			return null;
		}