Changeset 3613 for trunk/sources/HeuristicLab.Core/3.3/Constraints
- Timestamp:
- 05/05/10 00:09:10 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Core/3.3/Constraints
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Constraints/ComparisonConstraint.cs
r3602 r3613 44 44 45 45 public override IEnumerable<ConstraintOperation> AllowedConstraintOperations { 46 get { return new ConstraintOperation[6] { ConstraintOperation. Equal, ConstraintOperation.NotEqual, ConstraintOperation.Lesser, ConstraintOperation.LesserOrEqual, ConstraintOperation.Greater, ConstraintOperation.GreaterOrEqual }; }46 get { return new ConstraintOperation[6] { ConstraintOperation.Lesser, ConstraintOperation.LesserOrEqual, ConstraintOperation.Equal, ConstraintOperation.GreaterOrEqual, ConstraintOperation.Greater, ConstraintOperation.NotEqual }; } 47 47 } 48 48 -
trunk/sources/HeuristicLab.Core/3.3/Constraints/Constraint.cs
r3605 r3613 32 32 protected Constraint() { 33 33 this.Active = false; 34 if (AllowedConstraintOperations != null && AllowedConstraintOperations.Count() != 0) 35 this.ConstraintOperation = AllowedConstraintOperations.ElementAt(0); 34 36 } 35 37 [StorableConstructor] … … 65 67 public IItem ConstrainedValue { 66 68 get { return this.constrainedValue; } 67 protectedset {69 set { 68 70 if (value == null) 69 71 throw new ArgumentNullException("Constraint value cannot be null."); 70 72 if (this.constrainedValue != value) { 71 73 this.constrainedValue = value; 74 this.OnConstrainedValueChanged(); 72 75 this.OnToStringChanged(); 73 76 } … … 138 141 EventHandler handler = ActiveChanged; 139 142 if (handler != null) 140 ActiveChanged(this, EventArgs.Empty); 143 handler(this, EventArgs.Empty); 144 } 145 146 public event EventHandler ConstrainedValueChanged; 147 protected virtual void OnConstrainedValueChanged() { 148 EventHandler handler = ConstrainedValueChanged; 149 if (handler != null) 150 handler(this, EventArgs.Empty); 141 151 } 142 152 … … 145 155 EventHandler handler = ConstraintDataChanged; 146 156 if (handler != null) 147 ActiveChanged(this, EventArgs.Empty);157 handler(this, EventArgs.Empty); 148 158 } 149 159 … … 152 162 EventHandler handler = ConstraintOperationChanged; 153 163 if (handler != null) 154 ActiveChanged(this, EventArgs.Empty);164 handler(this, EventArgs.Empty); 155 165 } 156 166 #endregion … … 158 168 #region overriden item methods 159 169 public override string ToString() { 160 IItem constrained Value= GetConstrainedMember();170 IItem constrainedMember = GetConstrainedMember(); 161 171 string s = string.Empty; 162 if (constrainedValue != null) 163 s += constrainedValue.ToString(); 164 else 165 return "Could not determine constraint value."; 166 167 s += " " + ConstraintOperation.ToString() + " "; 172 if (constrainedMember != null) 173 s += constrainedMember.ToString() + " "; 174 175 if (constraintOperation != null) 176 s += ConstraintOperation.ToString() + " "; 168 177 169 178 if (constraintData != null) … … 178 187 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) { 179 188 Constraint clone = (Constraint)base.Clone(cloner); 180 clone.constrainedValue = (IItem)cloner.Clone(this.constrainedValue);189 clone.constrainedValue = null; //mkommend: intentional set to null and must be reset in the clone 181 190 182 191 IItem constraintDataItem = this.constraintData as IItem; -
trunk/sources/HeuristicLab.Core/3.3/Constraints/IConstraint.cs
r3602 r3613 26 26 27 27 namespace HeuristicLab.Core { 28 public interface IConstraint : IItem{28 public interface IConstraint : IItem { 29 29 bool Active { get; set; } 30 IItem ConstrainedValue { get; }30 IItem ConstrainedValue { get; set; } 31 31 ConstraintOperation ConstraintOperation { get; set; } 32 32 IEnumerable<ConstraintOperation> AllowedConstraintOperations { get; } … … 36 36 37 37 event EventHandler ActiveChanged; 38 event EventHandler ConstrainedValueChanged; 38 39 event EventHandler ConstraintDataChanged; 39 40 event EventHandler ConstraintOperationChanged;
Note: See TracChangeset
for help on using the changeset viewer.