Changeset 2852 for trunk/sources/HeuristicLab.Parameters
- Timestamp:
- 02/23/10 06:50:50 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Parameters/3.3
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.Parameters/3.3/HeuristicLab.Parameters-3.3.csproj ¶
r2803 r2852 67 67 <ItemGroup> 68 68 <None Include="HeuristicLabParametersPlugin.cs.frame" /> 69 <Compile Include="ConstrainedValueParameter.cs" /> 69 70 <Compile Include="LookupParameter.cs" /> 70 71 <Compile Include="SubScopesLookupParameter.cs" /> -
TabularUnified trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs ¶
r2834 r2852 108 108 return scope != null ? scope.Variables[actualName] : null; 109 109 } 110 //private IValueParameter GetProblemParameter(string name) {111 // IValueParameter param = null;112 // if (ExecutionContext.Problem.Parameters.ContainsKey(name)) {113 // param = ExecutionContext.Problem.Parameters[name] as IValueParameter;114 // if (param == null)115 // throw new InvalidOperationException(116 // string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\".",117 // name,118 // typeof(IValueParameter).GetPrettyName())119 // );120 // }121 // return param;122 //}123 110 protected override IItem GetActualValue() { 124 111 string name; … … 130 117 IVariable var = LookupVariable(name); 131 118 if (var != null) { 132 T value = var.Value as T; 133 if (value == null) 119 if (!(var.Value is T)) 134 120 throw new InvalidOperationException( 135 121 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", … … 137 123 typeof(T).GetPrettyName()) 138 124 ); 139 return va lue;125 return var.Value; 140 126 } 141 142 // try to get value from problem143 //IValueParameter problemParam = GetProblemParameter(name);144 //if (problemParam != null) return problemParam.Value;145 146 127 return null; 147 128 } 148 129 protected override void SetActualValue(IItem value) { 149 T val = value as T; 150 if (val == null) 130 if (!(value is T)) 151 131 throw new InvalidOperationException( 152 132 string.Format("Type mismatch. Value is not a \"{0}\".", … … 157 137 IValueParameter param = GetParameter(out name); 158 138 if (param != null) { 159 param.Value = val ;139 param.Value = value; 160 140 return; 161 141 } … … 164 144 IVariable var = LookupVariable(name); 165 145 if (var != null) { 166 var.Value = val ;146 var.Value = value; 167 147 return; 168 148 } 169 170 // try to set value in problem171 //IValueParameter problemParam = GetProblemParameter(name);172 //if (problemParam != null) {173 // problemParam.Value = val;174 // return;175 //}176 149 177 150 // create new variable -
TabularUnified trunk/sources/HeuristicLab.Parameters/3.3/SubScopesLookupParameter.cs ¶
r2818 r2852 45 45 if (var != null) { 46 46 value = var.Value as T; 47 if ( value == null)47 if ((var.Value != null) && (value == null)) 48 48 throw new InvalidOperationException( 49 49 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", -
TabularUnified trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs ¶
r2818 r2852 48 48 set { 49 49 T val = value as T; 50 if ( val == null)50 if ((value != null) && (val == null)) 51 51 throw new InvalidOperationException( 52 52 string.Format("Type mismatch. Value is not a \"{0}\".", -
TabularUnified trunk/sources/HeuristicLab.Parameters/3.3/ValueParameter.cs ¶
r2818 r2852 48 48 set { 49 49 T val = value as T; 50 if ( val == null)50 if ((value != null) && (val == null)) 51 51 throw new InvalidOperationException( 52 52 string.Format("Type mismatch. Value is not a \"{0}\".",
Note: See TracChangeset
for help on using the changeset viewer.