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

    r4068 r4722  
    4848      }
    4949    }
     50
     51    /// <summary>
     52    /// Instantiates a new CheckedItemList for deserialization.
     53    /// </summary>
     54    /// <param name="deserializing"></param>
     55    [StorableConstructor]
     56    protected CheckedItemList(bool deserializing) : base(deserializing) { }
     57    protected CheckedItemList(CheckedItemList<T> original, Cloner cloner)
     58      : base(original, cloner) {
     59      list = new List<T>(original.Select(x => (T)cloner.Clone(x)));
     60      checkedState = new Dictionary<T, bool>();
     61      foreach (var pair in original.checkedState)
     62        checkedState.Add(cloner.Clone(pair.Key), pair.Value);
     63    }
    5064    /// <summary>
    5165    /// Instantiates an empty CheckedItemList.
     
    7589      }
    7690    }
    77     /// <summary>
    78     /// Instantiates a new CheckedItemList for deserialization.
    79     /// </summary>
    80     /// <param name="deserializing"></param>
    81     [StorableConstructor]
    82     protected CheckedItemList(bool deserializing) : base(deserializing) { }
    8391
    8492    /// <summary>
     
    228236    /// <returns>A deep clone of the CheckedItemList</returns>
    229237    public override IDeepCloneable Clone(Cloner cloner) {
    230       CheckedItemList<T> clone = (CheckedItemList<T>)Activator.CreateInstance(this.GetType());
    231       cloner.RegisterClonedObject(this, clone);
    232       clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x)));
    233       clone.checkedState = new Dictionary<T, bool>();
    234       foreach (var pair in checkedState)
    235         clone.checkedState.Add((T)cloner.Clone(pair.Key), pair.Value);
    236       return clone;
     238      return new CheckedItemList<T>(this, cloner);
    237239    }
    238240  }
Note: See TracChangeset for help on using the changeset viewer.