예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XmlProxy"/> class.
 /// </summary>
 public XmlProxy()
 {
     mAttributes   = new XmlProxyAttributeCollection();
     mElementValue = string.Empty;
     mChilds       = new XmlProxyCollection(this);
 }
예제 #2
0
        /// <summary>
        /// Deserialize
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="context">The context.</param>
        protected virtual void Deserialize(SerializationInfo info, StreamingContext context)
        {
            try
            {
                // Element name
                mElementName = info.GetString("ElementName");

                mElementValue = info.GetString("ElementValue");

                /*
                 * // Element value
                 * string elementValueType = info.GetString("ElementValueType");
                 * if (elementValueType != string.Empty)
                 * {
                 *      Type t = Type.GetType(elementValueType);
                 *      object o = info.GetValue("ElementValue", t);
                 *      this.mElementValue = o;
                 * }
                 * else
                 * {
                 *      this.mElementValue = null;
                 * }
                 */

                // Attributes collection
                mAttributes = new XmlProxyAttributeCollection();
                int attrsCount = info.GetInt32("AttributesCount");
                for (int i = 0; i < attrsCount; i++)
                {
                    string si  = i.ToString();
                    string key = info.GetString("_att_k" + si);
                    string val = info.GetString("_att_v" + si);
                    mAttributes.Add(key, val);

                    /*
                     * string attrvalueType = info.GetString("_att_vt"+si);
                     * if (attrvalueType != string.Empty)
                     * {
                     *      Type t = Type.GetType(attrvalueType);
                     *      object o = info.GetValue("_att_v"+si, t);
                     *      this.mAttributes.Add(key, o);
                     * }
                     * else
                     * {
                     *      this.mAttributes.Add(key, null);
                     * }
                     */
                }

                // Childs collection
                mChilds = new XmlProxyCollection(this);
                mChilds.UpdateOwnerItem(this);
                int childCount = info.GetInt32("ChildsCount");
                for (int i = 0; i < childCount; i++)
                {
                    XmlProxy child = info.GetValue("_ch" + i, typeof(XmlProxy)) as XmlProxy;
                    mChilds.Add(child);
                }
            }
            catch (SerializationException e)
            {
                Debug.WriteLine("...Deserialization of DataTreeItem failed: " + e);
            }
        }