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(); } } }
public RemoveCmd(ProtocolNode parent, ProtocolNode child, List <ProtocolNode> list) { Parent = parent; Child = child; mOriginalId = child.Id; mList = list; }
public ProtocolWriter(ProtocolNode node, string path) { mTreeNode = node; mWriter = new XmlTextWriter(/*@"F:\protocol_idtest.xml"*/ path, null); writeProtocol(); }
public MoveCmd(ProtocolNode source, ProtocolNode parent, ProtocolNode child) { Source = source; SourceParent = (ProtocolNode)source.Parent; Index = SourceParent.Nodes.IndexOf(Source); Parent = parent; Child = child; }
public void _print(ProtocolNode node) { foreach (ProtocolNode n in node.Nodes) { print(n); _print(n); } }
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(); } }
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); } }
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(); } } } }
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(); } } }
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); } }
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); }
public AddCmd(ProtocolNode parent, ProtocolNode child) { Parent = parent; Child = child; }
public NudgeDownCmd(ProtocolNode currentNode) { mCurrentNode = currentNode; }
public static void Save(ProtocolNode node) { new ProtocolWriter(node, DefaultPath); }
public static void Load(ProtocolNode node, string path) { DefaultPath = path; new ProtocolReader(node, DefaultPath); }
public static void Load(ProtocolNode node) { new ProtocolReader(node, DefaultPath); }
public static void Save(ProtocolNode node, string path) { DefaultPath = path; new ProtocolWriter(node, DefaultPath); }
private ProtocolNode getNode() { var node = new ProtocolNode(); return(node); }
public ProtocolReader(ProtocolNode node, string path) { mProtocolNode = node; mPath = path; ReadTree(); }