public TACanvas Duplicate() { TACanvas duplicate = new TACanvas(); duplicate.LoadFromXml(this.Clone()); duplicate.Node.Text = this.Node.Text + "-Copy"; bool nameExist = true; while (nameExist) { nameExist = false; foreach (TreeNode node in this.Node.Parent.Nodes) { if (node.Text.Equals(duplicate.Node.Text, StringComparison.CurrentCultureIgnoreCase)) { duplicate.Node.Text = duplicate.Node.Text + "-Copy"; nameExist = true; break; } } } return(duplicate); }
public static TAModel LoadLTSFromXML(string text) { TAModel lts = new TAModel(); XmlDataDocument doc = new XmlDataDocument(); doc.LoadXml(text); XmlNodeList sitesNodes = doc.GetElementsByTagName(Parsing.DECLARATION_NODE_NAME); foreach (XmlElement component in sitesNodes) { lts.Declaration = component.InnerText; } sitesNodes = doc.GetElementsByTagName(Parsing.PROCESSES_NODE_NAME); if (sitesNodes.Count > 0) { foreach (XmlElement component in sitesNodes[0].ChildNodes) { TACanvas canvas = new TACanvas(); canvas.LoadFromXml(component); lts.Processes.Add(canvas); } } sitesNodes = doc.GetElementsByTagName(Parsing.PROPERTIES_NODE_NAME.Replace(" ", "_")); if (sitesNodes.Count > 0) { foreach (XmlElement component in sitesNodes[0].ChildNodes) { TACanvas canvas = new TACanvas(); canvas.LoadFromXml(component); lts.Properties.Add(canvas); } } return(lts); }