Exemple #1
0
        /// <summary>
        /// Adds a new property to the object.
        /// </summary>
        /// <param name="key">The name of the property.</param>
        /// <param name="value">The value of the property.</param>
        public void Add(string key, JavaScriptBoolean value)
        {
#if (NET20)
            list.Add(key, value);
#else
            keys.Add(key);
            list.Add(key, value);
#endif
        }
Exemple #2
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.AddInternal(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.AddInternal(p.Attributes["name"].Value, DeserialzeFromAjaxXml(p.ChildNodes[0]));
					}

					return o;
			}

			return null;
		}