Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/06/10 01:56:04 (13 years ago)
Author:
swagner
Message:

Merged cloning refactoring branch back into trunk (#922)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Core/3.3/Collections/ItemList.cs

    r4419 r4722  
    4646    }
    4747
     48    [StorableConstructor]
     49    protected ItemList(bool deserializing) : base(deserializing) { }
     50    protected ItemList(ItemList<T> original, Cloner cloner) {
     51      cloner.RegisterClonedObject(original, this);
     52      list = new List<T>(original.Select(x => cloner.Clone(x)));
     53    }
    4854    public ItemList() : base() { }
    4955    public ItemList(int capacity) : base(capacity) { }
    5056    public ItemList(IEnumerable<T> collection) : base(collection) { }
    51     [StorableConstructor]
    52     protected ItemList(bool deserializing) : base(deserializing) { }
    5357
    5458    public object Clone() {
     
    5660    }
    5761    public virtual IDeepCloneable Clone(Cloner cloner) {
    58       ItemList<T> clone = (ItemList<T>)Activator.CreateInstance(this.GetType());
    59       cloner.RegisterClonedObject(this, clone);
    60       clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x)));
    61       return clone;
     62      return new ItemList<T>(this, cloner);
    6263    }
    6364
Note: See TracChangeset for help on using the changeset viewer.