- Timestamp:
- 07/31/09 12:31:32 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionTreeBase.cs
r2216 r2218 25 25 using HeuristicLab.Core; 26 26 using HeuristicLab.GP.Interfaces; 27 using System.Xml; 27 28 28 29 namespace HeuristicLab.GP { … … 43 44 this.subTrees = new List<IFunctionTree>(original.SubTrees.Count); 44 45 foreach (IFunctionTree originalSubTree in original.SubTrees) { 45 this.SubTrees.Add( originalSubTree.Clone());46 this.SubTrees.Add((IFunctionTree)originalSubTree.Clone()); 46 47 } 47 48 } … … 93 94 } 94 95 95 public virtual IFunctionTree Clone() { 96 #endregion 97 98 #region IStorable Members 99 100 public Guid Guid { 101 get { throw new NotSupportedException(); } 102 } 103 104 public virtual object Clone() { 96 105 return new FunctionTreeBase(this); 106 } 107 108 public object Clone(IDictionary<Guid, object> clonedObjects) { 109 throw new NotImplementedException(); 110 } 111 112 public virtual XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) { 113 XmlNode node = document.CreateElement(name); 114 //XmlAttribute typeAttr = document.CreateAttribute("Type"); 115 //typeAttr.Value = PersistenceManager.BuildTypeString(GetType()); 116 //node.Attributes.Append(typeAttr); 117 foreach (IFunctionTree subTree in SubTrees) { 118 XmlNode funNode = PersistenceManager.Persist(Function, document, persistedObjects); 119 node.AppendChild(funNode); 120 funNode.AppendChild(subTree.GetXmlNode("Tree", document, persistedObjects)); 121 } 122 return node; 123 } 124 125 public virtual void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) { 126 for (int i = 0; i < node.ChildNodes.Count; i++) { 127 XmlNode childNode = node.ChildNodes[i]; 128 IFunction function = (IFunction)PersistenceManager.Restore(childNode, restoredObjects); 129 IFunctionTree tree = function.GetTreeNode(); 130 tree.Populate(childNode.SelectSingleNode("Tree"), restoredObjects); 131 AddSubTree(tree); 132 } 97 133 } 98 134
Note: See TracChangeset
for help on using the changeset viewer.