Changeset 14057 for trunk/sources
- Timestamp:
- 07/13/16 10:38:42 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs
r14056 r14057 171 171 string translatedName = Name; 172 172 var value = GetValue(ExecutionContext, ref translatedName); 173 if (value != null && !(value is T)) 174 throw new InvalidOperationException( 175 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 176 translatedName, 177 typeof(T).GetPrettyName()) 178 ); 173 179 CachedActualValue = value; 174 180 return value; 175 181 } 176 182 177 protected static IItem GetValue(IExecutionContext executionContext, ref string name , bool verifyType = true) {183 protected static IItem GetValue(IExecutionContext executionContext, ref string name) { 178 184 // try to get value from context stack 179 185 IValueParameter param = GetValueParameterAndTranslateName(executionContext, ref name); … … 182 188 // try to get variable from scope 183 189 IVariable var = LookupVariable(executionContext.Scope, name); 184 if (var != null) { 185 if (verifyType && !(var.Value is T)) 186 throw new InvalidOperationException( 187 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 188 name, 189 typeof(T).GetPrettyName()) 190 ); 191 return var.Value; 192 } 193 return null; 190 return var != null ? var.Value : null; 194 191 } 195 192
Note: See TracChangeset
for help on using the changeset viewer.