private void parseGroup(Group g, XmlNode node, Fix.Common.Model.Fix fix) { g.Name = node.Attributes["name"].Value; g.Required = node.Attributes["required"].Value == "Y"; LogHelper.Debug(string.Format("\t\tgroup:{0},{1}", g.Name, g.Required)); foreach (XmlNode xn in node.ChildNodes) { if (xn.Name == "field") { Field f = new Field(); f.Name = xn.Attributes["name"].Value; f.Required = xn.Attributes["required"].Value == "Y"; LogHelper.Debug(string.Format("\t\t\t\tfield:{0},{1}", f.Name, f.Required)); g.Fields.Add(f); } else if (xn.Name == "group") { Group gt = new Group(); parseGroup(gt, xn, fix); g.Groups.Add(gt); } else if (xn.Name == "component") { Component c = new Component(); parseComponent(c, xn, fix); g.Components.Add(c); } } }
private void parseMessage(Fix.Common.Model.Message m, XmlNode node, Fix.Common.Model.Fix fix) { m.Name = node.Attributes["name"].Value; m.MsgType = node.Attributes["msgtype"].Value; m.MsgCat = node.Attributes["msgcat"].Value; foreach (XmlNode xn in node.ChildNodes) { if (xn.Name == "field") { Field f = new Field(); f.Name = xn.Attributes["name"].Value; f.Required = xn.Attributes["required"].Value == "Y"; m.Fields.Add(f); } else if (xn.Name == "group") { Group gt = new Group(); parseGroup(gt, xn, fix); m.Groups.Add(gt); } else if (xn.Name == "component") { Component ct = new Component(); parseComponent(ct, xn, fix); m.Components.Add(ct); } } }
private void parseTrailer(XmlNode node, Fix.Common.Model.Fix fix) { foreach (XmlNode xn in node.ChildNodes) { if (xn.Name == "field") { Field f = new Field(); f.Name = xn.Attributes["name"].Value; f.Required = xn.Attributes["required"].Value == "Y"; fix.Trailer.Fields.Add(f); } else if (xn.Name == "group") { Group g = new Group(); parseGroup(g, xn, fix); fix.Trailer.Groups.Add(g); } else if (xn.Name == "component") { Component c = new Component(); parseComponent(c, xn, fix); fix.Trailer.Components.Add(c); } } }
private Fix.Common.Model.Fix parseFix(string path) { XmlDocument document = new XmlDocument(); document.Load(path); XmlNodeList fixNodes = document.GetElementsByTagName("fix"); XmlNode fixNode = fixNodes[0]; if (fixNode == null) { throw new Exception("错误的Fix文件"); } Fix.Common.Model.Fix fix = new Fix.Common.Model.Fix(); fix.Major = int.Parse(fixNode.Attributes["major"].Value); fix.Minor = int.Parse(fixNode.Attributes["minor"].Value); foreach (XmlNode node in fixNode.ChildNodes) { switch (node.Name) { case "header": parseHeader(node, fix); break; case "components": parseComponents(node, fix); break; case "messages": parseMessages(node, fix); break; case "fields": parseFields(node, fix); break; case "trailer": parseTrailer(node, fix); break; } } fix.Fields.Add(new FieldDic() { Name = "StandardHeader", Type = "STRING", Number = -1 }); fix.Fields.Add(new FieldDic() { Name = "StandardTrailer", Type = "STRING", Number = -1 }); foreach (var component in fix.Components) { fix.Fields.Add(new FieldDic() { Name = component.Name, Type = "STRING", Number = -1 }); } return(fix); }
private void loadFix() { SetTbDbEnable(false); ClearTree(); fixM = parseFix(FilePathHelper.FixXml); CreateRootNode(_tvFix.Nodes); //ExandAllTreeNode(); SetTbDbEnable(true); }
private void parseMessages(XmlNode node, Fix.Common.Model.Fix fix) { foreach (XmlNode xn in node.ChildNodes) { if (xn.Name == "message") { Fix.Common.Model.Message m = new Fix.Common.Model.Message(); parseMessage(m, xn, fix); fix.Messages.Add(m); } } }
private void parseComponents(XmlNode node, Fix.Common.Model.Fix fix) { foreach (XmlNode xn in node.ChildNodes) { if (xn.Name == "component") { Component c = new Component(); parseComponent(c, xn, fix); fix.Components.Add(c); } } }
private void parseFields(XmlNode node, Fix.Common.Model.Fix fix) { foreach (XmlNode xn in node.ChildNodes) { if ((xn.Name + "").ToLower() == "field") { FieldDic fd = new FieldDic(); parseFieldDic(fd, xn, fix); fix.Fields.Add(fd); } else { LogHelper.Warn(string.Format("{0} not field", xn.Name)); } } }
private void parseFieldDic(FieldDic fd, XmlNode node, Fix.Common.Model.Fix fix) { fd.Name = node.Attributes["name"].Value; fd.Number = int.Parse(node.Attributes["number"].Value); fd.Type = node.Attributes["type"].Value; LogHelper.Debug(string.Format("field:{0},{1},{2}", fd.Name, fd.Number, fd.Type)); foreach (XmlNode xn in node.ChildNodes) { if (xn.Name == "value") { Value v = new Value(); v.Enum = xn.Attributes["enum"].Value; v.Description = xn.Attributes["description"].Value; LogHelper.Debug(string.Format("\t\tvalue:{0},{1}", v.Enum, v.Description)); fd.Values.Add(v); } } }