/// <summary> /// Parse and load LTS from Xml /// </summary> /// <param name="text">Xml pure text</param> /// <returns></returns> public static PNModel LoadLTSFromXML(string text) { string assertion = string.Empty; List <PNCanvas> canvases = new List <PNCanvas>(); PNExtendInfo extendInfo = null; XmlDocument doc = new XmlDocument(); doc.LoadXml(text); XmlNodeList sitesNodes = doc.GetElementsByTagName(XmlTag.TAG_DECLARATION); //TODO? What is this for? foreach (XmlElement component in sitesNodes) { assertion = component.InnerText; } sitesNodes = doc.GetElementsByTagName(XmlTag.TAG_MODELS); if (sitesNodes.Count > 0) { foreach (XmlElement component in sitesNodes[0].ChildNodes) { // mlqvu -- set value for extend info // load topology from xml if (component.ChildNodes.Count == 4) { XmlElement topologyElement = (XmlElement)component.ChildNodes[0]; extendInfo = loadExtendInfo(topologyElement); } PNCanvas canvas = new PNCanvas(); canvas.LoadFromXml(component); canvases.Add(canvas); } } PNModel model = new PNModel(assertion, canvases); model.mExtendInfo = extendInfo; return(model); }
private XmlDocument GetDoc() { string declare = ""; if (this.DeclarationNode.Tag != null) { declare = this.DeclarationNode.Tag.ToString(); } List<PNCanvas> canvases = new List<PNCanvas>(); foreach (TreeNode processNode in ModelNode.Nodes) { if (processNode.Tag is PNCanvas) { PNCanvas canvas = (processNode.Tag as PNCanvas); //List<PNPlace> places = new List<PNPlace>(); //List<PNTransition> transitions = new List<PNTransition>(); //foreach (CanvasItemData itemData in canvas.itemsList) //{ // if (itemData.Item is PNPlace) // { // places.Add(itemData.Item as PNPlace); // } // if (itemData.Item is PNTransition) // { // transitions.Add(itemData.Item as PNTransition); // } //} //List<PNArc> arcs = new List<PNArc>(); //foreach (Route route in canvas.diagramRouter.Routes) //{ // if (route is PNArc) // { // arcs.Add(route as PNArc); // } //} canvases.Add(canvas); } } PNModel pn = new PNModel(declare, canvases); pn.mExtendInfo = mExtendInfo; return pn.GenerateXML(); }
/// <summary> /// Parse and load LTS from Xml /// </summary> /// <param name="text">Xml pure text</param> /// <returns></returns> public static PNModel LoadLTSFromXML(string text) { string assertion = string.Empty; List<PNCanvas> canvases = new List<PNCanvas>(); PNExtendInfo extendInfo = null; XmlDocument doc = new XmlDocument(); doc.LoadXml(text); XmlNodeList sitesNodes = doc.GetElementsByTagName(XmlTag.TAG_DECLARATION); //TODO? What is this for? foreach (XmlElement component in sitesNodes) assertion = component.InnerText; sitesNodes = doc.GetElementsByTagName(XmlTag.TAG_MODELS); if (sitesNodes.Count > 0) { foreach (XmlElement component in sitesNodes[0].ChildNodes) { // mlqvu -- set value for extend info // load topology from xml if (component.ChildNodes.Count == 4) { XmlElement topologyElement = (XmlElement)component.ChildNodes[0]; extendInfo = loadExtendInfo(topologyElement); } PNCanvas canvas = new PNCanvas(); canvas.LoadFromXml(component); canvases.Add(canvas); } } PNModel model = new PNModel(assertion, canvases); model.mExtendInfo = extendInfo; return model; }