Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/27/10 03:55:16 (15 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • implemented ideas which came up during today's presentation of HeuristicLab.Core and related plugins
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.3/ItemParameter.cs

    r2685 r2687  
    8484
    8585    public override IItem GetValue(ExecutionContext context) {
    86       return GetValue(context, true);
    87     }
    88     public override IItem GetValue(ExecutionContext context, bool throwOnError) {
    89       if (Value != null) return Value;
    90 
    91       ExecutionContext current, child;
    92       IParameter parameter = null;
    93       child = context;
    94       current = context.Parent;
    95       while ((current != null) && (parameter == null)) {
    96         current.Operator.Parameters.TryGetValue(ActualName, out parameter);
    97         child = current;
     86      ItemParameter param = this;
     87      ExecutionContext current = context;
     88      string actualName = null;
     89      while (param != null) {
     90        if (param.Value != null) return param.Value;
     91        actualName = param.ActualName;
    9892        current = current.Parent;
     93        while ((current != null) && !current.Operator.Parameters.ContainsKey(actualName))
     94          current = current.Parent;
     95        if (current != null)
     96          param = (ItemParameter)current.Operator.Parameters[actualName];
     97        else
     98          param = null;
    9999      }
    100100
    101       if (parameter != null) return parameter.GetValue(child, throwOnError);
    102       else {
    103         Variable variable = context.Scope.Lookup(ActualName, true, throwOnError);
    104         return variable == null ? null : variable.Value;
    105       }
     101      IScope scope = context.Scope;
     102      while ((scope != null) && !scope.Variables.ContainsKey(actualName))
     103        scope = scope.Parent;
     104      return scope != null ? scope.Variables[actualName].Value : null;
    106105    }
    107106
     
    157156
    158157    public new T GetValue(ExecutionContext context) {
    159       return GetValue(context, true);
    160     }
    161     public new T GetValue(ExecutionContext context, bool throwOnError) {
    162       return (T)base.GetValue(context, throwOnError);
     158      return (T)base.GetValue(context);
    163159    }
    164160  }
Note: See TracChangeset for help on using the changeset viewer.