Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/29/10 17:38:42 (14 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/Constraints/Constraint.cs

    r4345 r4668  
    3131    [StorableConstructor]
    3232    protected Constraint(bool deserializing) : base(deserializing) { }
     33    protected Constraint(Constraint original, Cloner cloner)
     34      : base(original, cloner) {
     35      constrainedValue = null;  //mkommend: intentionally set to null;
    3336
     37      IItem constraintDataItem = original.constraintData as IItem;
     38      ICloneable constraintDataCloneable = original.constraintData as ICloneable;
     39      if (constraintDataItem != null)
     40        constraintData = cloner.Clone(constraintDataItem);
     41      else if (constraintDataCloneable != null)
     42        constraintData = constraintDataCloneable.Clone();
     43      else
     44        constraintData = original.constraintData;
     45
     46      constraintOperation = original.constraintOperation;
     47    }
    3448    protected Constraint() {
    3549      this.Active = false;
     
    138152    protected virtual void OnActiveChanged() {
    139153      EventHandler handler = ActiveChanged;
    140       if (handler != null)
    141         handler(this, EventArgs.Empty);
     154      if (handler != null) handler(this, EventArgs.Empty);
    142155    }
    143156
     
    145158    protected virtual void OnConstrainedValueChanged() {
    146159      EventHandler handler = ConstrainedValueChanged;
    147       if (handler != null)
    148         handler(this, EventArgs.Empty);
     160      if (handler != null) handler(this, EventArgs.Empty);
    149161    }
    150162
     
    152164    protected virtual void OnConstraintDataChanged() {
    153165      EventHandler handler = ConstraintDataChanged;
    154       if (handler != null)
    155         handler(this, EventArgs.Empty);
     166      if (handler != null) handler(this, EventArgs.Empty);
    156167    }
    157168
     
    159170    protected virtual void OnConstraintOperationChanged() {
    160171      EventHandler handler = ConstraintOperationChanged;
    161       if (handler != null)
    162         handler(this, EventArgs.Empty);
     172      if (handler != null) handler(this, EventArgs.Empty);
    163173    }
    164174    #endregion
     
    182192      return s;
    183193    }
    184 
    185     public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {
    186       Constraint clone = (Constraint)base.Clone(cloner);
    187       clone.constrainedValue = null;  //mkommend: intentionally set to null;
    188 
    189       IItem constraintDataItem = this.constraintData as IItem;
    190       ICloneable constraintDataCloneable = this.constraintData as ICloneable;
    191       if (constraintDataItem != null)
    192         clone.constraintData = cloner.Clone(constraintDataItem);
    193       else if (constraintDataCloneable != null)
    194         clone.constraintData = constraintDataCloneable.Clone();
    195       else
    196         clone.constraintData = constraintData;
    197 
    198       clone.constraintOperation = this.constraintOperation;
    199 
    200       return clone;
    201     }
    202194    #endregion
    203195  }
Note: See TracChangeset for help on using the changeset viewer.