Changeset 2042 for branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/CloneableBase.cs
- Timestamp:
- 06/15/09 02:18:42 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Operator Architecture Refactoring/HeuristicLab.Core/3.3/CloneableBase.cs
r2033 r2042 31 31 /// </summary> 32 32 public abstract class CloneableBase : ICloneable { 33 /// <summary>34 /// Gets a unique id (memory address) of the current instance. The id is used to35 /// detect, if an object has already been cloned or not.36 /// </summary>37 public long Id {38 get {39 GCHandle handle = new GCHandle();40 handle.Target = this;41 return GCHandle.ToIntPtr(handle).ToInt64();42 }43 }44 45 /// <summary>46 /// Clones the current instance (deep clone).47 /// </summary>48 /// <remarks>Uses the <see cref="Auxiliary.Clone"/> method of the class <see cref="Auxiliary"/>.</remarks>49 /// <returns>The clone.</returns>50 33 public object Clone() { 51 return Auxiliary.Clone(this, new Dictionary<long, object>());34 return Clone(new Cloner()); 52 35 } 53 36 /// <summary> … … 57 40 /// <param name="clonedObjects">All already cloned objects.</param> 58 41 /// <returns>The clone.</returns> 59 public virtual object Clone(IDictionary<long, object> clonedObjects) {42 public virtual ICloneable Clone(ICloner cloner) { 60 43 CloneableBase clone = (CloneableBase)Activator.CreateInstance(this.GetType()); 61 clone dObjects.Add(clone.Id, clone);44 cloner.AddClonedObject(this, clone); 62 45 return clone; 63 46 }
Note: See TracChangeset
for help on using the changeset viewer.