- Timestamp:
- 02/08/10 03:43:36 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs
r2756 r2757 32 32 /// A parameter whose value is retrieved from the scope. 33 33 /// </summary> 34 [Item("LookupParameter<T>", "A parameter whose value is retrieved from thescope.")]34 [Item("LookupParameter<T>", "A parameter whose value is retrieved from or written to a scope.")] 35 35 public class LookupParameter<T> : Parameter, ILookupParameter<T> where T : class, IItem { 36 36 [Storable] … … 46 46 } 47 47 } 48 public T ActualValue {49 get { return GetActualValue(); }48 public new T ActualValue { 49 get { return (T)GetActualValue(); } 50 50 set { SetActualValue(value); } 51 51 } … … 80 80 return scope != null ? scope.Variables[actualName] : null; 81 81 } 82 protected virtual TGetActualValue() {82 protected override IItem GetActualValue() { 83 83 string name = TranslateName(Name, ExecutionContext); 84 84 IVariable var = LookupVariable(name); … … 95 95 return null; 96 96 } 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 ); 98 104 string name = TranslateName(Name, ExecutionContext); 99 105 IVariable var = LookupVariable(name); 100 if (var != null) var.Value = val ue;101 else ExecutionContext.Scope.Variables.Add(new Variable(name, val ue));106 if (var != null) var.Value = val; 107 else ExecutionContext.Scope.Variables.Add(new Variable(name, val)); 102 108 } 103 109
Note: See TracChangeset
for help on using the changeset viewer.