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/ItemDictionary.cs

    r4419 r4668  
    4848    }
    4949
     50    [StorableConstructor]
     51    protected ItemDictionary(bool deserializing) : base(deserializing) { }
     52    protected ItemDictionary(ItemDictionary<TKey, TValue> original, Cloner cloner) {
     53      cloner.RegisterClonedObject(original, this);
     54      foreach (TKey key in dict.Keys)
     55        dict.Add(cloner.Clone<TKey>(key), cloner.Clone<TValue>(dict[key]));
     56    }
    5057    public ItemDictionary() : base() { }
    5158    public ItemDictionary(int capacity) : base(capacity) { }
    5259    public ItemDictionary(IDictionary<TKey, TValue> dictionary) : base(dictionary) { }
    53     [StorableConstructor]
    54     protected ItemDictionary(bool deserializing) : base(deserializing) { }
    5560
    5661    public object Clone() {
     
    5863    }
    5964    public virtual IDeepCloneable Clone(Cloner cloner) {
    60       ItemDictionary<TKey, TValue> clone = (ItemDictionary<TKey, TValue>)Activator.CreateInstance(this.GetType());
    61       cloner.RegisterClonedObject(this, clone);
    62       foreach (TKey key in dict.Keys)
    63         clone.dict.Add((TKey)cloner.Clone(key), (TValue)cloner.Clone(dict[key]));
    64       return clone;
     65      return new ItemDictionary<TKey, TValue>(this, cloner);
    6566    }
    6667
Note: See TracChangeset for help on using the changeset viewer.