Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/02/08 21:10:17 (16 years ago)
Author:
gkronber
Message:

Refactored cloning in all plugins except: HL.Communication, HL.Hive, HL.GP, HL.Routing, HL.Scheduling, HL.SimOpt, HL.Visualization

#285 (Cloning could be improved by creating objects at the bottom of the cloning chain with 'new' instead of the top with Activator.CreateInstance())

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CloningRefactorBranch/HeuristicLab.Core/OperatorBase.cs

    r885 r887  
    105105
    106106    /// <summary>
    107     /// Copy constructor.
    108     /// </summary>
    109     /// <param name="original">The original instance to be cloned</param>
     107    /// Copy constructor to create deep clones reusing already cloned object references.
     108    /// </summary>
     109    /// <param name="original">The instance to be cloned.</param>
    110110    /// <param name="clonedObjects">Already cloned objects (for referential integrity).</param>
    111111    protected OperatorBase(OperatorBase original, IDictionary<Guid, object> clonedObjects)
     
    130130    public override IView CreateView() {
    131131      return new OperatorBaseView(this);
     132    }
     133
     134    /// <summary>
     135    /// Creates a deep clone with the copy constructor reusing already cloned
     136    /// object references.
     137    /// </summary>
     138    /// <param name="clonedObjects">Already cloned objects (for referential integrity).</param>
     139    /// <returns>The cloned instance.</returns>
     140    public override object Clone(IDictionary<Guid, object> clonedObjects) {
     141      // override clone for all classes inheriting from OperatorBase, so
     142      // we don't need to implement Clone() and the copy constructors in
     143      // every single operator.
     144      return Activator.CreateInstance(this.GetType(), this, clonedObjects);
    132145    }
    133146
Note: See TracChangeset for help on using the changeset viewer.