public ERACanvas Duplicate() { ERACanvas duplicate = new ERACanvas(); 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 ERAModel LoadLTSFromXML(string text) { ERAModel lts = new ERAModel(); 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) { ERACanvas canvas = new ERACanvas(); 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) { ERACanvas canvas = new ERACanvas(); canvas.LoadFromXml(component); lts.Properties.Add(canvas); } } return(lts); }