Changeset 4722 for trunk/sources/HeuristicLab.Core/3.3/Constraints
- Timestamp:
- 11/06/10 01:56:04 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
/branches/CloningRefactoring (added) merged: 4656-4693,4696-4697,4711-4714,4718-4719
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Core/3.3/Constraints/ComparisonConstraint.cs
r4153 r4722 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 26 … … 30 31 [StorableConstructor] 31 32 protected ComparisonConstraint(bool deserializing) : base(deserializing) { } 32 33 protected ComparisonConstraint(ComparisonConstraint original, Cloner cloner) : base(original, cloner) { } 33 34 public ComparisonConstraint() : base() { } 34 35 public ComparisonConstraint(IItem constrainedValue, ConstraintOperation comparisonOperation, object comparisonValue) … … 41 42 public override IEnumerable<ConstraintOperation> AllowedConstraintOperations { 42 43 get { return new ConstraintOperation[6] { ConstraintOperation.Less, ConstraintOperation.LessOrEqual, ConstraintOperation.Equal, ConstraintOperation.GreaterOrEqual, ConstraintOperation.Greater, ConstraintOperation.NotEqual }; } 44 } 45 46 public override IDeepCloneable Clone(Cloner cloner) { 47 return new ComparisonConstraint(this, cloner); 43 48 } 44 49 -
trunk/sources/HeuristicLab.Core/3.3/Constraints/Constraint.cs
r4345 r4722 31 31 [StorableConstructor] 32 32 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; 33 36 37 IDeepCloneable constraintDataDeepCloneable = original.constraintData as IDeepCloneable; 38 ICloneable constraintDataCloneable = original.constraintData as ICloneable; 39 if (constraintDataDeepCloneable != null) 40 constraintData = cloner.Clone(constraintDataDeepCloneable); 41 else if (constraintDataCloneable != null) 42 constraintData = constraintDataCloneable.Clone(); 43 else 44 constraintData = original.constraintData; 45 46 constraintOperation = original.constraintOperation; 47 } 34 48 protected Constraint() { 35 49 this.Active = false; … … 138 152 protected virtual void OnActiveChanged() { 139 153 EventHandler handler = ActiveChanged; 140 if (handler != null) 141 handler(this, EventArgs.Empty); 154 if (handler != null) handler(this, EventArgs.Empty); 142 155 } 143 156 … … 145 158 protected virtual void OnConstrainedValueChanged() { 146 159 EventHandler handler = ConstrainedValueChanged; 147 if (handler != null) 148 handler(this, EventArgs.Empty); 160 if (handler != null) handler(this, EventArgs.Empty); 149 161 } 150 162 … … 152 164 protected virtual void OnConstraintDataChanged() { 153 165 EventHandler handler = ConstraintDataChanged; 154 if (handler != null) 155 handler(this, EventArgs.Empty); 166 if (handler != null) handler(this, EventArgs.Empty); 156 167 } 157 168 … … 159 170 protected virtual void OnConstraintOperationChanged() { 160 171 EventHandler handler = ConstraintOperationChanged; 161 if (handler != null) 162 handler(this, EventArgs.Empty); 172 if (handler != null) handler(this, EventArgs.Empty); 163 173 } 164 174 #endregion … … 182 192 return s; 183 193 } 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 else196 clone.constraintData = constraintData;197 198 clone.constraintOperation = this.constraintOperation;199 200 return clone;201 }202 194 #endregion 203 195 } -
trunk/sources/HeuristicLab.Core/3.3/Constraints/EqualityConstraint.cs
r4153 r4722 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 26 … … 30 31 [StorableConstructor] 31 32 protected EqualityConstraint(bool deserializing) : base(deserializing) { } 32 33 protected EqualityConstraint(EqualityConstraint original, Cloner cloner) : base(original, cloner) { } 33 34 public EqualityConstraint() : base() { } 34 35 public EqualityConstraint(IItem constrainedValue, ConstraintOperation constraintOperation, object constraintData) … … 41 42 public override IEnumerable<ConstraintOperation> AllowedConstraintOperations { 42 43 get { return new ConstraintOperation[2] { ConstraintOperation.Equal, ConstraintOperation.NotEqual }; } 44 } 45 46 public override IDeepCloneable Clone(Cloner cloner) { 47 return new EqualityConstraint(this, cloner); 43 48 } 44 49 -
trunk/sources/HeuristicLab.Core/3.3/Constraints/TypeCompatibilityConstraint.cs
r4153 r4722 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 26 … … 28 29 [Item("TypeCompatibilityConstraint", "A constraint that checks for compatible types.")] 29 30 public class TypeCompatibilityConstraint : Constraint { 30 public TypeCompatibilityConstraint() {31 }32 31 [StorableConstructor] 33 32 protected TypeCompatibilityConstraint(bool deserializing) : base(deserializing) { } 33 protected TypeCompatibilityConstraint(TypeCompatibilityConstraint original, Cloner cloner) : base(original, cloner) { } 34 public TypeCompatibilityConstraint() : base() { } 34 35 public TypeCompatibilityConstraint(IItem constrainedValue, ConstraintOperation constraintOperation, Type constraintData) 35 36 : base(constrainedValue, constraintOperation, constraintData) { … … 46 47 public override IEnumerable<ConstraintOperation> AllowedConstraintOperations { 47 48 get { return new ConstraintOperation[2] { ConstraintOperation.IsTypeCompatible, ConstraintOperation.IsTypeNotCompatible }; } 49 } 50 51 public override IDeepCloneable Clone(Cloner cloner) { 52 return new TypeCompatibilityConstraint(this, cloner); 48 53 } 49 54
Note: See TracChangeset
for help on using the changeset viewer.