Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3598


Ignore:
Timestamp:
05/03/10 17:43:58 (15 years ago)
Author:
mkommend
Message:

changed ctors of constraints (ticket #996)

Location:
trunk/sources/HeuristicLab.Data/3.3/Constraints
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data/3.3/Constraints/ComparisonConstraint.cs

    r3592 r3598  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Data.Constraints {
     29namespace HeuristicLab.Data {
    3030  [StorableClass]
    3131  [Item("ComparisonConstraint", "A constraint which checks for specified compare operation.")]
     
    3939    }
    4040
    41     public ComparisonConstraint(IItem constrainedValue)
    42       : base(constrainedValue) {
     41    public ComparisonConstraint(IItem constrainedValue, ComparisonOperation comparisonOperation, object comparisonValue)
     42      : base() {
     43      this.ConstrainedValue = constrainedValue;
     44      this.ComparisonOperation = comparisonOperation;
     45      this.ComparisonValue = comparisonValue;
    4346    }
    4447
  • trunk/sources/HeuristicLab.Data/3.3/Constraints/ComparisonOperation.cs

    r3592 r3598  
    2222using System.Collections.Generic;
    2323using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    24 [StorableClass]
    25 public sealed class ComparisonOperation {
    26   public static readonly ComparisonOperation Equal = new ComparisonOperation(0, "Equal");
    27   public static readonly ComparisonOperation NotEqual = new ComparisonOperation(1, "Not equal");
    28   public static readonly ComparisonOperation Lesser = new ComparisonOperation(2, "Lesser");
    29   public static readonly ComparisonOperation LesserOrEqual = new ComparisonOperation(3, "Lesser or equal");
    30   public static readonly ComparisonOperation Greater = new ComparisonOperation(4, "Greater");
    31   public static readonly ComparisonOperation GreaterOrEqual = new ComparisonOperation(5, "Greater or equal");
    32   public static readonly ComparisonOperation IsTypeOf = new ComparisonOperation(6, "Is type of");
    33   public static readonly ComparisonOperation IsNotTypeOf = new ComparisonOperation(7, "Is not type of");
     24namespace HeuristicLab.Data {
     25  [StorableClass]
     26  public sealed class ComparisonOperation {
     27    public static readonly ComparisonOperation Equal = new ComparisonOperation(0, "Equal");
     28    public static readonly ComparisonOperation NotEqual = new ComparisonOperation(1, "Not equal");
     29    public static readonly ComparisonOperation Lesser = new ComparisonOperation(2, "Lesser");
     30    public static readonly ComparisonOperation LesserOrEqual = new ComparisonOperation(3, "Lesser or equal");
     31    public static readonly ComparisonOperation Greater = new ComparisonOperation(4, "Greater");
     32    public static readonly ComparisonOperation GreaterOrEqual = new ComparisonOperation(5, "Greater or equal");
     33    public static readonly ComparisonOperation IsTypeOf = new ComparisonOperation(6, "Is type of");
     34    public static readonly ComparisonOperation IsNotTypeOf = new ComparisonOperation(7, "Is not type of");
    3435
    35   [Storable]
    36   private int value;
    37   [Storable]
    38   private string name;
    39   [StorableConstructor]
    40   private ComparisonOperation() {
    41     value = -1;
    42     name = "empty";
    43   }
    44   private ComparisonOperation(int value, string name) {
    45     this.value = value;
    46     this.name = name;
    47   }
     36    [Storable]
     37    private int value;
     38    [Storable]
     39    private string name;
     40    [StorableConstructor]
     41    private ComparisonOperation() {
     42      value = -1;
     43      name = "empty";
     44    }
     45    private ComparisonOperation(int value, string name) {
     46      this.value = value;
     47      this.name = name;
     48    }
    4849
    49   public override string ToString() {
    50     return name;
    51   }
     50    public override string ToString() {
     51      return name;
     52    }
    5253
    53   public override bool Equals(object obj) {
    54     if (obj is ComparisonOperation)
    55       return this == (ComparisonOperation)obj;
     54    public override bool Equals(object obj) {
     55      if (obj is ComparisonOperation)
     56        return this == (ComparisonOperation)obj;
    5657
    57     return false;
    58   }
    59   public override int GetHashCode() {
    60     return value;
    61   }
    62   public static bool operator ==(ComparisonOperation co1, ComparisonOperation co2) {
    63     return co1.value == co2.value;
    64   }
    65   public static bool operator !=(ComparisonOperation co1, ComparisonOperation co2) {
    66     return !(co1 == co2);
     58      return false;
     59    }
     60    public override int GetHashCode() {
     61      return value;
     62    }
     63    public static bool operator ==(ComparisonOperation co1, ComparisonOperation co2) {
     64      return co1.value == co2.value;
     65    }
     66    public static bool operator !=(ComparisonOperation co1, ComparisonOperation co2) {
     67      return !(co1 == co2);
     68    }
    6769  }
    6870}
  • trunk/sources/HeuristicLab.Data/3.3/Constraints/Constraint.cs

    r3592 r3598  
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2929
    30 namespace HeuristicLab.Data.Constraints {
     30namespace HeuristicLab.Data {
    3131  [StorableClass]
    3232  public abstract class Constraint : Item, IConstraint {
     
    3939    }
    4040
    41     public Constraint(IItem constrainedValue)
     41    public Constraint(IItem constrainedValue,ComparisonOperation comparisonOperation, object comparisonValue)
    4242      : this() {
    4343      this.ConstrainedValue = constrainedValue;
     44      this.ComparisonOperation = comparisonOperation;
     45      this.ComparisonValue = comparisonValue;
    4446    }
    4547
  • trunk/sources/HeuristicLab.Data/3.3/Constraints/EqualityConstraint.cs

    r3592 r3598  
    2828using HeuristicLab.Common;
    2929
    30 namespace HeuristicLab.Data.Constraints {
     30namespace HeuristicLab.Data {
    3131  [StorableClass]
    3232  [Item("EqualityConstraint", "A constraint which checks for equality")]
     
    4040    }
    4141
    42     public EqualityConstraint(IItem constrainedValue)
    43       : base(constrainedValue) {
     42    public EqualityConstraint(IItem constrainedValue, ComparisonOperation comparisonOperation, object compareValue)
     43      : base() {
     44      this.ConstrainedValue = constrainedValue;
     45      this.ComparisonOperation = comparisonOperation;
     46      this.ComparisonValue = ComparisonValue;
    4447    }
    4548
  • trunk/sources/HeuristicLab.Data/3.3/Constraints/IConstraint.cs

    r3592 r3598  
    2626using HeuristicLab.Core;
    2727
    28 namespace HeuristicLab.Data.Constraints {
     28namespace HeuristicLab.Data {
    2929  public interface IConstraint: IItem{
    3030    bool Active { get; set; }
  • trunk/sources/HeuristicLab.Data/3.3/Constraints/TypeConstraint.cs

    r3592 r3598  
    2727using HeuristicLab.Core;
    2828
    29 namespace HeuristicLab.Data.Constraints {
     29namespace HeuristicLab.Data {
    3030  [StorableClass]
    3131  [Item("TypeConstraint", "A constraint which checks the types for specified compare operation.")]
     
    3939    }
    4040
    41     public TypeConstraint(IItem constrainedValue)
    42       : base(constrainedValue) {
     41    public TypeConstraint(IItem constrainedValue, ComparisonOperation comparisonOperation, Type comparisonValue)
     42      : base() {
     43      this.ConstrainedValue = constrainedValue;
     44      this.ComparisonOperation = comparisonOperation;
     45      this.ComparisonValue = comparisonValue;
    4346    }
    4447
Note: See TracChangeset for help on using the changeset viewer.