Exemple #1
0
 /// <summary>
 /// Item (child node) by index
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public virtual VXmlNode this[int index]
 {
     get
     {
         if (node_ids == null)
         {
             return(null);
         }
         else
         {
             return(((index >= node_ids.Count) | (index < 0)) ? null : node.GetNode(node_ids[index]));
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Serialize node
        /// </summary>
        /// <param name="node"></param>
        public void Serialize(VXmlNode node, short level)
        {
            Level = level;

            Type    = node.NodeTypeCode;
            Name    = node.Name;
            Value   = node.Value;
            Content = null;

            VXmlContent ct = null;

            if (Type == DEFX.NODE_TYPE_CONTENT)
            {
                ct      = (VXmlContent)node.GetNode(node.Id);
                Content = ct.ContentBytes;
            }

            VXmlAttributeCollection ac = node.Attributes;
            VXmlCommentCollection   cc = node.CommentNodes;
            VXmlTextCollection      tx = node.TextNodes;
            VXmlTagCollection       tt = node.TagNodes;


            byte[] br = new byte[RESERVE_LENGTH];                   // Reserve

            // Fixed part
            IO.Write(-1, level);                                          // +08(2) - level
            IO.Write(-1, Type);                                           // +10(2) - node type
            IO.Write(-1, (short)Name.Length);                             // +12(2) - name length
            IO.Write(-1, (long)Value.Length);                             // +14(8) - value length
            IO.Write(-1, (long)((Content == null) ? 0 : Content.Length)); // +22(8) - content length
            IO.Write(-1, (int)ac.Count);                                  // +30(4)   Number of attrs
            IO.Write(-1, (int)cc.Count);                                  // +34(4)   Number of comments
            IO.Write(-1, (int)tx.Count);                                  // +34(4)   number of text nodes
            IO.Write(-1, (int)tt.Count);                                  // +38(4)   number of tags
            IO.Write(-1, ref br);                                         // +42(16)- reserve

            // Variable part
            IO.Write(-1, node.Name);        // Name

            if (Value.Length > 0)
            {
                IO.Write(-1, Value);        // Value
            }
            if (Content != null)
            {
                IO.Write(-1, ref Content); // Content
            }
            // Write attributes
            for (int i = 0; i < ac.Count; i++)
            {
                IO.Write(-1, (short)ac[i].Name.Length);      // Attr name length
                IO.Write(-1, ac[i].Name);                    // Attr name

                IO.Write(-1, (int)ac[i].Value.Length);       // Attr value length
                IO.Write(-1, ac[i].Value);                   // Attr value
            }

            // Write comments
            for (int i = 0; i < cc.Count; i++)
            {
                IO.Write(-1, (int)cc[i].Value.Length);       // Comment value length
                IO.Write(-1, cc[i].Value);                   // Comment value
            }

            // Write text
            for (int i = 0; i < tx.Count; i++)
            {
                IO.Write(-1, (int)tx[i].Value.Length);       // Text value length
                IO.Write(-1, tx[i].Value);                   // Text value
            }

            // Write tags
            for (int i = 0; i < tt.Count; i++)
            {
                IO.Write(-1, (int)tt[i].Value.Length);       // Tag value length
                IO.Write(-1, tt[i].Value);                   // Tag value
            }
        }