Пример #1
0
        private void writeNode(ProtocolNode node)
        {
            mWriter.WriteStartElement("Id");
            mWriter.WriteValue(node.Id);
            mWriter.WriteEndElement();

            mWriter.WriteStartElement("LinkId");
            mWriter.WriteValue(node.LinkId);
            mWriter.WriteEndElement();

            mWriter.WriteStartElement("LinkText");
            mWriter.WriteValue(node.LinkText);
            mWriter.WriteEndElement();

            mWriter.WriteStartElement("text");
            mWriter.WriteValue(node.Element.Text != null ? node.Element.Text : "empty");
            mWriter.WriteEndElement();

            if (node.Element.SubTextList.Count > 0)
            {
                foreach (var str in node.Element.SubTextList)
                {
                    mWriter.WriteStartElement("SubText");
                    mWriter.WriteValue(str);
                    mWriter.WriteEndElement();
                }
            }
        }
Пример #2
0
 public RemoveCmd(ProtocolNode parent, ProtocolNode child, List <ProtocolNode> list)
 {
     Parent      = parent;
     Child       = child;
     mOriginalId = child.Id;
     mList       = list;
 }
Пример #3
0
        public ProtocolWriter(ProtocolNode node, string path)
        {
            mTreeNode = node;

            mWriter = new XmlTextWriter(/*@"F:\protocol_idtest.xml"*/ path, null);
            writeProtocol();
        }
Пример #4
0
 public MoveCmd(ProtocolNode source, ProtocolNode parent, ProtocolNode child)
 {
     Source       = source;
     SourceParent = (ProtocolNode)source.Parent;
     Index        = SourceParent.Nodes.IndexOf(Source);
     Parent       = parent;
     Child        = child;
 }
Пример #5
0
 public void _print(ProtocolNode node)
 {
     foreach (ProtocolNode n in node.Nodes)
     {
         print(n);
         _print(n);
     }
 }
Пример #6
0
 private static void readTextNode(XmlReader reader, ProtocolNode node)
 {
     if (reader.LocalName.Equals("text"))
     {
         node.Element.Text = reader.ReadString();
         node.Text         = node.Element.Text.Length > 32 ? node.Element.Text.Remove(32) + "...." : node.Element.Text;
         reader.Read();
     }
 }
Пример #7
0
        private void print(ProtocolNode node)
        {
            var tab = "";

            for (var i = 0; i < node.Level; i++)
            {
                tab += "\t";
            }
            Console.WriteLine(tab + node.Element.Text);

            foreach (var subString in node.Element.SubTextList)
            {
                Console.WriteLine(tab + subString);
            }
        }
Пример #8
0
        private void _writeNode(ProtocolNode node)
        {
            if (node != null)
            {
                writeNode(node);

                if (node.Nodes.Count > 0)
                {
                    foreach (ProtocolNode cur in node.Nodes)
                    {
                        mWriter.WriteStartElement("SubSection");
                        _writeNode(cur);
                        mWriter.WriteEndElement();
                    }
                }
            }
        }
Пример #9
0
        private void ReadNode(XmlReader reader, ProtocolNode node)
        {
            reader.ReadToFollowing("Id");

            if (reader.LocalName.Equals("Id"))
            {
                var id = int.Parse(reader.ReadString());
                if (id == -1)
                {
                    id      = UniqueId.GetId();
                    node.Id = id;
                }
                else
                {
                    node.Id = id;
                }

                reader.Read();
            }

            if (reader.LocalName.Equals("LinkId"))
            {
                node.LinkId = int.Parse(reader.ReadString());
                reader.Read();
            }

            if (reader.LocalName.Equals("LinkText"))
            {
                node.LinkText = reader.ReadString();
                reader.Read();
            }

            readTextNode(reader, node);

            if (reader.LocalName.Equals("SubText"))
            {
                node.Element.SubTextList.Add(reader.ReadString());
                reader.Read();
                while (reader.LocalName.Equals("SubText"))
                {
                    node.Element.SubTextList.Add(reader.ReadString());
                    reader.Read();
                }
            }
        }
Пример #10
0
 private void _processSubNodes(XmlReader reader, XmlReader dataReader, ProtocolNode parentNode,
                               ProtocolNode childNode)
 {
     if (reader.ReadToDescendant("SubSection"))
     {
         // printNode(reader);
         var descendantNode = getNode();
         ReadNode(dataReader, descendantNode);
         childNode.Nodes.Add(descendantNode);
         _processSubNodes(reader, dataReader, childNode, descendantNode);
     }
     if (reader.ReadToNextSibling("SubSection"))
     {
         //printNode(reader);
         var siblingNode = getNode();
         ReadNode(dataReader, siblingNode);
         parentNode.Nodes.Add(siblingNode);
         _processSubNodes(reader, dataReader, parentNode, siblingNode);
     }
 }
Пример #11
0
        public override object Clone()
        {
            var cloneNode = new ProtocolNode();

            if (Nodes.Count > 0)
            {
                foreach (ProtocolNode node in Nodes)
                {
                    cloneNode.Nodes.Add(node.Clone() as ProtocolNode);
                }
            }
            cloneNode.Text      = Text;
            cloneNode.IsSection = IsSection;
            cloneNode.Element   = Element;
            cloneNode.Tag       = Tag;
            cloneNode.Id        = Id;
            cloneNode.LinkId    = LinkId;
            cloneNode.LinkText  = LinkText;

            return(cloneNode);
        }
Пример #12
0
 public AddCmd(ProtocolNode parent, ProtocolNode child)
 {
     Parent = parent;
     Child  = child;
 }
Пример #13
0
 public NudgeDownCmd(ProtocolNode currentNode)
 {
     mCurrentNode = currentNode;
 }
Пример #14
0
 public static void Save(ProtocolNode node)
 {
     new ProtocolWriter(node, DefaultPath);
 }
Пример #15
0
 public static void Load(ProtocolNode node, string path)
 {
     DefaultPath = path;
     new ProtocolReader(node, DefaultPath);
 }
Пример #16
0
 public static void Load(ProtocolNode node)
 {
     new ProtocolReader(node, DefaultPath);
 }
Пример #17
0
 public static void Save(ProtocolNode node, string path)
 {
     DefaultPath = path;
     new ProtocolWriter(node, DefaultPath);
 }
Пример #18
0
        private ProtocolNode getNode()
        {
            var node = new ProtocolNode();

            return(node);
        }
Пример #19
0
 public ProtocolReader(ProtocolNode node, string path)
 {
     mProtocolNode = node;
     mPath         = path;
     ReadTree();
 }