Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/29/10 17:38:42 (13 years ago)
Author:
swagner
Message:

Finished cloning refactoring of HeuristicLab.Common, HeuristicLab.Collections and HeuristicLab.Core (#922)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CloningRefactoring/HeuristicLab.Core/3.3/Collections/ItemArray.cs

    r4419 r4668  
    4646    }
    4747
     48    [StorableConstructor]
     49    protected ItemArray(bool deserializing) : base(deserializing) { }
     50    protected ItemArray(ItemArray<T> original, Cloner cloner) {
     51      cloner.RegisterClonedObject(original, this);
     52      array = original.Select(x => cloner.Clone<T>(x)).ToArray();
     53    }
    4854    public ItemArray() : base() { }
    4955    public ItemArray(int length) : base(length) { }
    5056    public ItemArray(T[] array) : base(array) { }
    5157    public ItemArray(IEnumerable<T> collection) : base(collection) { }
    52     [StorableConstructor]
    53     protected ItemArray(bool deserializing) : base(deserializing) { }
    5458
    5559    public object Clone() {
     
    5761    }
    5862    public virtual IDeepCloneable Clone(Cloner cloner) {
    59       ItemArray<T> clone = (ItemArray<T>)Activator.CreateInstance(this.GetType());
    60       cloner.RegisterClonedObject(this, clone);
    61       clone.array = this.Select(x => (T)cloner.Clone(x)).ToArray();
    62       return clone;
     63      return new ItemArray<T>(this, cloner);
    6364    }
    6465
Note: See TracChangeset for help on using the changeset viewer.