/// <summary> /// Make sure the GraphNodeInfo, held in the UserObject property, /// is specific for the newly copied GraphNode. /// </summary> /// <param name="env"></param> /// <returns></returns> public override GoObject CopyObject(GoCopyDictionary env) { GraphNode newobj = (GraphNode)base.CopyObject(env); if (newobj != null) { if (newobj.UserObject != null) { try { var oldTool = newobj.UserObject as ToolBase; newobj.UserObject = Activator.CreateInstance(newobj.UserObject.GetType()); var newTool = newobj.UserObject as ToolBase; (newobj.UserObject as ToolBase).graphNode = newobj; for (int i = 0; i < newTool.Settings.Count(); i++) { newTool.Settings[i].Value = oldTool.Settings[i].DeepCopyValue(); } //(newobj.UserObject as ToolBase).Settings = oldTool.Settings.DeepCopy(); } catch (Exception e) { //throw; } } else { newobj.UserObject = new ToolBase(newobj); } } //newobj.Text += " copy"; return(newobj); }
public override GoObject CopyObject(GoCopyDictionary env) { var copy = (MultiPortContainerNode)base.CopyObject(env); copy._portNodes = new Dictionary <NeighborLink, PortNode>(); return(copy); }
//Called during deserialization to create new objects instead of constructor //Care for reference members in CopyObject, because of object copy process in deserialization public override GoObject CopyObject(GoCopyDictionary env) { var copy = (ReactionNode)base.CopyObject(env); copy._triangle = (GoTriangle)copy.Shape; copy._eductsPort = (ReactionPort)copy.FindChild("EductsPort"); copy._productsPort = (ReactionPort)copy.FindChild("ProductsPort"); copy._modifiersPort = (ReactionPort)copy.FindChild("ModulatorsPort"); return(copy); }
/// <summary> /// Creates a new instance of the <see cref="T:Northwoods.Go.Xml.GoXmlSimpleData" />-inheriting class /// and copies all of the property values -- copying <see cref="T:Northwoods.Go.GoObject" />s /// and cloning <c>ICloneable</c>s. /// </summary> /// <returns>an instance of this same <see cref="T:Northwoods.Go.Xml.GoXmlSimpleData" />-inheriting type</returns> public object Clone() { GoXmlSimpleData goXmlSimpleData = (GoXmlSimpleData)Activator.CreateInstance(GetType()); Dictionary <string, object> dictionary = goXmlSimpleData.myTable; GoCopyDictionary goCopyDictionary = new GoCopyDictionary(); foreach (KeyValuePair <string, object> item in myTable) { GoObject goObject = item.Value as GoObject; if (goObject != null) { dictionary[item.Key] = goCopyDictionary.CopyComplete(goObject); } else { ICloneable cloneable = goObject as ICloneable; if (cloneable != null) { dictionary[item.Key] = cloneable.Clone(); } } } return(goXmlSimpleData); }
public override GoObject CopyObject(GoCopyDictionary env) { var copy = (JournalPageNode)base.CopyObject(env); return(copy); }