Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/08/10 03:43:36 (14 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on parameters and operators
File:
1 edited

Legend:

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

    r2756 r2757  
    3232  /// A parameter whose value is retrieved from the scope.
    3333  /// </summary>
    34   [Item("LookupParameter<T>", "A parameter whose value is retrieved from the scope.")]
     34  [Item("LookupParameter<T>", "A parameter whose value is retrieved from or written to a scope.")]
    3535  public class LookupParameter<T> : Parameter, ILookupParameter<T> where T : class, IItem {
    3636    [Storable]
     
    4646      }
    4747    }
    48     public T ActualValue {
    49       get { return GetActualValue(); }
     48    public new T ActualValue {
     49      get { return (T)GetActualValue(); }
    5050      set { SetActualValue(value); }
    5151    }
     
    8080      return scope != null ? scope.Variables[actualName] : null;
    8181    }
    82     protected virtual T GetActualValue() {
     82    protected override IItem GetActualValue() {
    8383      string name = TranslateName(Name, ExecutionContext);
    8484      IVariable var = LookupVariable(name);
     
    9595      return null;
    9696    }
    97     protected virtual void SetActualValue(T value) {
     97    protected override void SetActualValue(IItem value) {
     98      T val = value as T;
     99      if (val == null)
     100        throw new InvalidOperationException(
     101          string.Format("Type mismatch. Value is not a \"{0}\".",
     102                        typeof(T).GetPrettyName())
     103        );
    98104      string name = TranslateName(Name, ExecutionContext);
    99105      IVariable var = LookupVariable(name);
    100       if (var != null) var.Value = value;
    101       else ExecutionContext.Scope.Variables.Add(new Variable(name, value));
     106      if (var != null) var.Value = val;
     107      else ExecutionContext.Scope.Variables.Add(new Variable(name, val));
    102108    }
    103109
Note: See TracChangeset for help on using the changeset viewer.