Ejemplo n.º 1
0
        /// <summary>
        /// Add packet item attribute.
        /// </summary>
        /// <param name="Key">Attribute key name.</param>
        /// <param name="Value">Attribute value.</param>
        /// <returns>Added <see cref="XmlProxyAttribute"/> object.</returns>
        public XmlProxyAttribute Add(string Key, string Value)
        {
            XmlProxyAttribute attr = new XmlProxyAttribute(Key, Value);

            List.Add(attr);
            return(attr);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set attribute value.
        /// </summary>
        /// <param name="Key">Attribute key name.</param>
        /// <param name="Value">Value for attribute.</param>
        public void SetValue(string Key, string Value)
        {
            XmlProxyAttribute attr = this[Key];

            if (attr != null)
            {
                attr.Value = Value;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get value of attribute.
        /// </summary>
        /// <param name="Key">Attribute key name.</param>
        /// <returns>Returns value of attribute specified by <c>Key</c>.</returns>
        public string GetValue(string Key)
        {
            XmlProxyAttribute attr = this[Key];

            if ((attr != null) && (attr.Value != null))
            {
                return(attr.Value);
            }
            return(string.Empty);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets index of attribute.
        /// </summary>
        /// <param name="Key">Attribute key name.</param>
        /// <returns>Returns index of attribute specified by <c>Key</c> if attribute if found, or -1 if not found.</returns>
        public int IndexOf(string Key)
        {
            for (int i = 0; i < List.Count; i++)
            {
                XmlProxyAttribute attr = List[i] as XmlProxyAttribute;
                if (string.Compare(attr.Key, Key, true) == 0)
                {
                    return(i);
                }
            }

            return(-1);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Serialization of DataTreeItem
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> to populate with data.</param>
        /// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"/>) for this serialization.</param>
        /// <exception cref="T:System.Security.SecurityException">
        /// The caller does not have the required permission.
        /// </exception>
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            try
            {
                info.AddValue("ElementName", ElementName);
                if (ElementValue != null)
                {
                    info.AddValue("ElementValue", ElementValue);
                }
                else
                {
                    info.AddValue("ElementValue", string.Empty);
                }

                info.AddValue("AttributesCount", mAttributes.Count);

                //int si=0;
                for (int si = 0; si < mAttributes.Count; si++)
                {
                    XmlProxyAttribute attr = mAttributes[si];

                    info.AddValue("_att_k" + si, attr.Key);
                    info.AddValue("_att_v" + si, attr.Value);
                }

                /*
                 * foreach(string key in mAttributes.Keys)
                 * {
                 *      string val = mAttributes.GetValue(Key);
                 *      info.AddValue("_att_k"+si, key);
                 *      if (val != null) info.AddValue("_att_v"+si, val);
                 *      else info.AddValue("_att_v"+si, string.Empty);
                 *      si++;
                 * }
                 */

                info.AddValue("ChildsCount", Childs.Count);
                for (int i = 0; i < Childs.Count; i++)
                {
                    info.AddValue("_ch" + i, Childs[i]);
                }
            }
            catch (SerializationException e)
            {
                Debug.WriteLine("...Serialization of DataTreeItem failed: " + e);
            }
        }
Ejemplo n.º 6
0
        public void Serialize(XmlProxy item, XmlWriter writer)
        {
            writer.WriteStartElement(item.ElementName);
            for (int i = 0; i < item.Attributes.Count; i++)
            {
                XmlProxyAttribute attr = item.Attributes[i];
                writer.WriteAttributeString(attr.Key, attr.Value);
            }

            writer.WriteString(item.ElementValue);

            foreach (XmlProxy child in item.Childs)
            {
                Serialize(child, writer);
            }
            writer.WriteEndElement();
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Remove packet item attribute from collection.
 /// </summary>
 /// <param name="attribute"><see cref="XmlProxyAttribute"/> object to remove.</param>
 public void Remove(XmlProxyAttribute attribute)
 {
     List.Remove(attribute);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Add packet item attribute.
 /// </summary>
 /// <param name="attribute"><see cref="XmlProxyAttribute"/> object to add.</param>
 /// <returns>Index of added object in collection.</returns>
 public int Add(XmlProxyAttribute attribute)
 {
     return(List.Add(attribute));
 }