Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/15/10 05:26:02 (15 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on operators, parameters and problems
Location:
trunk/sources/HeuristicLab.Parameters/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Parameters/3.3/SubScopesLookupParameter.cs

    r2793 r2796  
    3333  /// </summary>
    3434  [Item("SubScopesLookupParameter<T>", "A generic parameter representing instances of type T which are collected from or written to the sub-scopes of the current scope.")]
    35   public class SubScopesLookupParameter<T> : Parameter, ILookupParameter<T> where T : class, IItem {
    36     [Storable]
    37     private string actualName;
    38     public string ActualName {
    39       get { return actualName; }
    40       set {
    41         if (value == null) throw new ArgumentNullException();
    42         if (!actualName.Equals(value)) {
    43           actualName = value;
    44           OnActualNameChanged();
    45         }
    46       }
    47     }
    48 
    49     public new ItemArray<T> ActualValue {
    50       get { return (ItemArray<T>)GetActualValue(); }
    51       set { SetActualValue(value); }
    52     }
    53 
    54     public SubScopesLookupParameter()
    55       : base("Anonymous", typeof(ItemArray<T>)) {
    56       actualName = Name;
    57     }
    58     public SubScopesLookupParameter(string name)
    59       : base(name, typeof(ItemArray<T>)) {
    60       actualName = Name;
    61     }
    62     public SubScopesLookupParameter(string name, string description)
    63       : base(name, description, typeof(ItemArray<T>)) {
    64       actualName = Name;
    65     }
    66 
    67     public override IDeepCloneable Clone(Cloner cloner) {
    68       SubScopesLookupParameter<T> clone = (SubScopesLookupParameter<T>)base.Clone(cloner);
    69       clone.actualName = actualName;
    70       return clone;
    71     }
    72 
    73     public override string ToString() {
    74       return string.Format("{0}: {1} ({2})", Name, ActualName, DataType.Name);
    75     }
     35  public class SubScopesLookupParameter<T> : LookupParameter<ItemArray<T>> where T : class, IItem {
     36    public SubScopesLookupParameter() : base() { }
     37    public SubScopesLookupParameter(string name) : base(name) { }
     38    public SubScopesLookupParameter(string name, string description) : base(name, description) { }
    7639
    7740    protected override IItem GetActualValue() {
     
    11578      }
    11679    }
    117 
    118     public event EventHandler ActualNameChanged;
    119     private void OnActualNameChanged() {
    120       if (ActualNameChanged != null)
    121         ActualNameChanged(this, EventArgs.Empty);
    122       OnChanged();
    123     }
    12480  }
    12581}
  • trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs

    r2793 r2796  
    4747      }
    4848    }
     49    IItem IValueParameter.Value {
     50      get { return Value; }
     51      set {
     52        T val = value as T;
     53        if (val == null)
     54          throw new InvalidOperationException(
     55            string.Format("Type mismatch. Value is not a \"{0}\".",
     56                          typeof(T).GetPrettyName())
     57          );
     58        Value = val;
     59      }
     60    }
    4961
    5062    public ValueLookupParameter()
  • trunk/sources/HeuristicLab.Parameters/3.3/ValueParameter.cs

    r2793 r2796  
    4747      }
    4848    }
    49     public new T ActualValue {
     49    IItem IValueParameter.Value {
    5050      get { return Value; }
    51       set { Value = value; }
     51      set {
     52        T val = value as T;
     53        if (val == null)
     54          throw new InvalidOperationException(
     55            string.Format("Type mismatch. Value is not a \"{0}\".",
     56                          typeof(T).GetPrettyName())
     57          );
     58        Value = val;
     59      }
    5260    }
    5361
     
    8492    }
    8593    protected override void SetActualValue(IItem value) {
    86       T val = value as T;
    87       if (val == null)
    88         throw new InvalidOperationException(
    89           string.Format("Type mismatch. Value is not a \"{0}\".",
    90                         typeof(T).GetPrettyName())
    91         );
    92       Value = val;
     94      ((IValueParameter)this).Value = value;
    9395    }
    9496
Note: See TracChangeset for help on using the changeset viewer.