- Timestamp:
- 12/02/08 14:13:06 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactorBranch/HeuristicLab.Data/ConstrainedItemList.cs
r737 r885 53 53 54 54 /// <summary> 55 /// Copy constructor to create clones (deep). 56 /// </summary> 57 /// <param name="original">The original instance to be cloned.</param> 58 public ConstrainedItemList(ConstrainedItemList original) : this(original, new Dictionary<Guid, object>()) { } 59 60 /// <summary> 61 /// Copy constructor to create clones (deep) reusing already cloned object references. 62 /// </summary> 63 /// <param name="original">The instance to be cloned.</param> 64 /// <param name="clonedObjects">Already cloned objects (for referential integrity).</param> 65 protected ConstrainedItemList(ConstrainedItemList original, IDictionary<Guid, object> clonedObjects) 66 : base(original, clonedObjects) { 67 foreach (IConstraint constraint in original.Constraints) 68 this.AddConstraint((IConstraint)Auxiliary.Clone(constraint, clonedObjects)); 69 this.suspendConstraintCheck = original.suspendConstraintCheck; 70 foreach (IItem item in original.list) { 71 this.list.Add((IItem)Auxiliary.Clone(item, clonedObjects)); 72 } 73 } 74 75 /// <summary> 55 76 /// Creates a new instance of <see cref="ConstrainedItemListView"/>. 56 77 /// </summary> … … 64 85 /// Clones the current instance. 65 86 /// </summary> 66 /// <remarks>The elements of the current instance are cloned with the 67 /// <see cref="HeuristicLab.Core.Auxiliary.Clone"/> method of the class <see cref="Auxiliary"/>.</remarks> 87 /// <remarks>The elements of the current instance are cloned with the copy constructor.</remarks> 68 88 /// <param name="clonedObjects">A dictionary of all already cloned objects.</param> 69 89 /// <returns>The cloned instance as <see cref="ConstrainedItemList"/>.</returns> 70 90 public override object Clone(IDictionary<Guid, object> clonedObjects) { 71 ConstrainedItemList clone = new ConstrainedItemList(); 72 clonedObjects.Add(Guid, clone); 73 foreach (IConstraint constraint in Constraints) 74 clone.AddConstraint((IConstraint)Auxiliary.Clone(constraint, clonedObjects)); 75 clone.suspendConstraintCheck = suspendConstraintCheck; 76 foreach (IItem item in list) { 77 clone.list.Add((IItem)Auxiliary.Clone(item, clonedObjects)); 78 } 79 return clone; 91 return new ConstrainedItemList(this, clonedObjects); 80 92 } 81 93 … … 94 106 /// <param name="persistedObjects">A dictionary of all already persisted objects. (Needed to avoid cycles.)</param> 95 107 /// <returns>The saved <see cref="XmlNode"/>.</returns> 96 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {108 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) { 97 109 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 98 110 XmlNode listNode = document.CreateNode(XmlNodeType.Element, "ListItems", null); … … 115 127 /// <param name="node">The <see cref="XmlNode"/> where the int is saved.</param> 116 128 /// <param name="restoredObjects">A dictionary of all already restored objects. (Needed to avoid cycles.)</param> 117 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {129 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) { 118 130 base.Populate(node, restoredObjects); 119 131 XmlNode listNode = node.SelectSingleNode("ListItems");
Note: See TracChangeset
for help on using the changeset viewer.