- Timestamp:
- 03/18/19 17:24:30 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ConstrainedValueParameter.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/FixedValueParameter.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/LookupParameter.cs
r13404 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 50 50 public string TranslatedName { 51 51 get { 52 string translatedName ;53 GetValueParameterAndTranslateName( outtranslatedName);52 string translatedName = Name; 53 GetValueParameterAndTranslateName(ExecutionContext, ref translatedName); 54 54 return translatedName; 55 55 } … … 61 61 62 62 private Lazy<ThreadLocal<IItem>> cachedActualValues; 63 pr ivateIItem CachedActualValue {63 protected IItem CachedActualValue { 64 64 get { return cachedActualValues.Value.Value; } 65 set { cachedActualValues.Value.Value = value; } 65 66 } 66 67 … … 129 130 } 130 131 131 pr ivate IValueParameter GetValueParameterAndTranslateName(out string actualName) {132 protected static IValueParameter GetValueParameterAndTranslateName(IExecutionContext executionContext, ref string translatedName) { 132 133 IValueParameter valueParam; 133 134 ILookupParameter lookupParam; 134 IExecutionContext currentExecutionContext = ExecutionContext; 135 136 actualName = Name; 135 IExecutionContext currentExecutionContext = executionContext; 136 137 137 while (currentExecutionContext != null) { 138 valueParam = currentExecutionContext.Parameters[actualName] as IValueParameter; 139 lookupParam = currentExecutionContext.Parameters[actualName] as ILookupParameter; 138 IParameter param = null; 139 while (currentExecutionContext != null && !currentExecutionContext.Parameters.TryGetValue(translatedName, out param)) 140 currentExecutionContext = currentExecutionContext.Parent; 141 if (currentExecutionContext == null) break; 142 143 valueParam = param as IValueParameter; 144 lookupParam = param as ILookupParameter; 140 145 141 146 if ((valueParam == null) && (lookupParam == null)) 142 147 throw new InvalidOperationException( 143 148 string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\" or an \"{2}\".", 144 actualName, typeof(IValueParameter).GetPrettyName(), typeof(ILookupParameter).GetPrettyName())149 translatedName, typeof(IValueParameter).GetPrettyName(), typeof(ILookupParameter).GetPrettyName()) 145 150 ); 146 151 … … 149 154 else if (lookupParam == null) return valueParam; 150 155 } 151 if (lookupParam != null) actualName = lookupParam.ActualName;156 translatedName = lookupParam.ActualName; 152 157 153 158 currentExecutionContext = currentExecutionContext.Parent; 154 while ((currentExecutionContext != null) && !currentExecutionContext.Parameters.ContainsKey(actualName))155 currentExecutionContext = currentExecutionContext.Parent;156 159 } 157 160 return null; 158 161 } 159 pr ivate IVariable LookupVariable(string name) {160 I Scope scope = ExecutionContext.Scope;161 while ( (scope != null) && !scope.Variables.ContainsKey(name))162 protected static IVariable LookupVariable(IScope scope, string name) { 163 IVariable variable = null; 164 while (scope != null && !scope.Variables.TryGetValue(name, out variable)) 162 165 scope = scope.Parent; 163 return scope != null ? scope.Variables[name] : null; 164 } 166 return scope != null ? variable : null; 167 } 168 165 169 protected override IItem GetActualValue() { 166 170 if (CachedActualValue != null) return CachedActualValue; 167 string name; 171 172 string translatedName = Name; 173 var value = GetValue(ExecutionContext, ref translatedName); 174 if (value != null && !(value is T)) 175 throw new InvalidOperationException( 176 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 177 translatedName, 178 typeof(T).GetPrettyName()) 179 ); 180 CachedActualValue = value; 181 return value; 182 } 183 184 protected static IItem GetValue(IExecutionContext executionContext, ref string name) { 168 185 // try to get value from context stack 169 IValueParameter param = GetValueParameterAndTranslateName( outname);186 IValueParameter param = GetValueParameterAndTranslateName(executionContext, ref name); 170 187 if (param != null) return param.Value; 171 188 172 189 // try to get variable from scope 173 IVariable var = LookupVariable(name); 174 if (var != null) { 175 if (!(var.Value is T)) 176 throw new InvalidOperationException( 177 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 178 name, 179 typeof(T).GetPrettyName()) 180 ); 181 cachedActualValues.Value.Value = var.Value; 182 return var.Value; 183 } 184 return null; 185 } 190 IVariable var = LookupVariable(executionContext.Scope, name); 191 return var != null ? var.Value : null; 192 } 193 186 194 protected override void SetActualValue(IItem value) { 187 195 if (!(value is T)) … … 190 198 typeof(T).GetPrettyName()) 191 199 ); 192 cachedActualValues.Value.Value = value; 193 200 CachedActualValue = value; 201 202 string translatedName = Name; 203 SetValue(ExecutionContext, ref translatedName, value); 204 } 205 206 protected static void SetValue(IExecutionContext executionContext, ref string name, IItem value) { 194 207 // try to set value in context stack 195 string name; 196 IValueParameter param = GetValueParameterAndTranslateName(out name); 208 IValueParameter param = GetValueParameterAndTranslateName(executionContext, ref name); 197 209 if (param != null) { 198 210 param.Value = value; … … 201 213 202 214 // try to set value in scope 203 IVariable var = LookupVariable( name);215 IVariable var = LookupVariable(executionContext.Scope, name); 204 216 if (var != null) { 205 217 var.Value = value; … … 208 220 209 221 // create new variable 210 ExecutionContext.Scope.Variables.Add(new Variable(name, value));222 executionContext.Scope.Variables.Add(new Variable(name, value)); 211 223 } 212 224 -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/OperatorParameter.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/Parameter.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/Plugin.cs.frame
r13321 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 /// Plugin class for HeuristicLab.Parameters plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Parameters", "3.3.1 3.$WCREV$")]28 [Plugin("HeuristicLab.Parameters", "3.3.15.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Parameters-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Collections", "3.3")] -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/Properties/AssemblyInfo.cs.frame
r13321 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 32 32 [assembly: AssemblyCompany("")] 33 33 [assembly: AssemblyProduct("HeuristicLab")] 34 [assembly: AssemblyCopyright("(c) 2002-201 5HEAL")]34 [assembly: AssemblyCopyright("(c) 2002-2018 HEAL")] 35 35 [assembly: AssemblyTrademark("")] 36 36 [assembly: AssemblyCulture("")] … … 54 54 // by using the '*' as shown below: 55 55 [assembly: AssemblyVersion("3.3.0.0")] 56 [assembly: AssemblyFileVersion("3.3.1 3.$WCREV$")]56 [assembly: AssemblyFileVersion("3.3.15.$WCREV$")] -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ScopeParameter.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ScopeTreeLookupParameter.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ValueParameter.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab.
Note: See TracChangeset
for help on using the changeset viewer.