Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/06/10 01:56:04 (14 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.Problems.ArtificialAnt/3.3/ArtificialAntProblem.cs

    r4419 r4722  
    196196    [StorableConstructor]
    197197    private ArtificialAntProblem(bool deserializing) : base(deserializing) { }
     198    [StorableHook(HookType.AfterDeserialization)]
     199    private void AfterDeserialization() {
     200      // BackwardsCompatibility3.3
     201      #region Backwards compatible code (remove with 3.4)
     202      if (operators == null) InitializeOperators();
     203      #endregion
     204      AttachEventHandlers();
     205    }
     206
     207    private ArtificialAntProblem(ArtificialAntProblem original, Cloner cloner)
     208      : base(original, cloner) {
     209      operators = original.operators.Select(x => cloner.Clone(x)).ToList();
     210      AttachEventHandlers();
     211    }
     212    public override IDeepCloneable Clone(Cloner cloner) {
     213      return new ArtificialAntProblem(this, cloner);
     214    }
    198215    public ArtificialAntProblem()
    199216      : base() {
     
    222239    }
    223240
    224     public override IDeepCloneable Clone(Cloner cloner) {
    225       ArtificialAntProblem clone = (ArtificialAntProblem)base.Clone(cloner);
    226       clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
    227       clone.AttachEventHandlers();
    228       return clone;
    229     }
    230 
    231241    #region Events
    232242    public event EventHandler SolutionCreatorChanged;
     
    278288
    279289    #region Helpers
    280     [StorableHook(HookType.AfterDeserialization)]
    281     private void AfterDeserializationHook() {
    282       // BackwardsCompatibility3.3
    283       #region Backwards compatible code (remove with 3.4)
    284       if (operators == null) InitializeOperators();
    285       #endregion
    286       AttachEventHandlers();
    287     }
    288 
    289290    private void AttachEventHandlers() {
    290291      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
Note: See TracChangeset for help on using the changeset viewer.