- Timestamp:
- 06/28/18 11:13:37 (6 years ago)
- Location:
- branches/2522_RefactorPluginInfrastructure
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2522_RefactorPluginInfrastructure
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/ConstrainedValueParameter.cs
r12012 r15973 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/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/FixedValueParameter.cs
r12012 r15973 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/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/LookupParameter.cs
r12012 r15973 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 … … 128 129 } 129 130 130 pr ivate IValueParameter GetValueParameterAndTranslateName(out string actualName) {131 protected static IValueParameter GetValueParameterAndTranslateName(IExecutionContext executionContext, ref string translatedName) { 131 132 IValueParameter valueParam; 132 133 ILookupParameter lookupParam; 133 IExecutionContext currentExecutionContext = ExecutionContext; 134 135 actualName = Name; 134 IExecutionContext currentExecutionContext = executionContext; 135 136 136 while (currentExecutionContext != null) { 137 valueParam = currentExecutionContext.Parameters[actualName] as IValueParameter; 138 lookupParam = currentExecutionContext.Parameters[actualName] as ILookupParameter; 137 IParameter param = null; 138 while (currentExecutionContext != null && !currentExecutionContext.Parameters.TryGetValue(translatedName, out param)) 139 currentExecutionContext = currentExecutionContext.Parent; 140 if (currentExecutionContext == null) break; 141 142 valueParam = param as IValueParameter; 143 lookupParam = param as ILookupParameter; 139 144 140 145 if ((valueParam == null) && (lookupParam == null)) 141 146 throw new InvalidOperationException( 142 147 string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\" or an \"{2}\".", 143 actualName, typeof(IValueParameter).GetPrettyName(), typeof(ILookupParameter).GetPrettyName())148 translatedName, typeof(IValueParameter).GetPrettyName(), typeof(ILookupParameter).GetPrettyName()) 144 149 ); 145 150 … … 148 153 else if (lookupParam == null) return valueParam; 149 154 } 150 if (lookupParam != null) actualName = lookupParam.ActualName;155 translatedName = lookupParam.ActualName; 151 156 152 157 currentExecutionContext = currentExecutionContext.Parent; 153 while ((currentExecutionContext != null) && !currentExecutionContext.Parameters.ContainsKey(actualName))154 currentExecutionContext = currentExecutionContext.Parent;155 158 } 156 159 return null; 157 160 } 158 pr ivate IVariable LookupVariable(string name) {159 I Scope scope = ExecutionContext.Scope;160 while ( (scope != null) && !scope.Variables.ContainsKey(name))161 protected static IVariable LookupVariable(IScope scope, string name) { 162 IVariable variable = null; 163 while (scope != null && !scope.Variables.TryGetValue(name, out variable)) 161 164 scope = scope.Parent; 162 return scope != null ? scope.Variables[name] : null; 163 } 165 return scope != null ? variable : null; 166 } 167 164 168 protected override IItem GetActualValue() { 165 169 if (CachedActualValue != null) return CachedActualValue; 166 string name; 170 171 string translatedName = Name; 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 ); 179 CachedActualValue = value; 180 return value; 181 } 182 183 protected static IItem GetValue(IExecutionContext executionContext, ref string name) { 167 184 // try to get value from context stack 168 IValueParameter param = GetValueParameterAndTranslateName( outname);185 IValueParameter param = GetValueParameterAndTranslateName(executionContext, ref name); 169 186 if (param != null) return param.Value; 170 187 171 188 // try to get variable from scope 172 IVariable var = LookupVariable(name); 173 if (var != null) { 174 if (!(var.Value is T)) 175 throw new InvalidOperationException( 176 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 177 name, 178 typeof(T).GetPrettyName()) 179 ); 180 cachedActualValues.Value.Value = var.Value; 181 return var.Value; 182 } 183 return null; 184 } 189 IVariable var = LookupVariable(executionContext.Scope, name); 190 return var != null ? var.Value : null; 191 } 192 185 193 protected override void SetActualValue(IItem value) { 186 194 if (!(value is T)) … … 189 197 typeof(T).GetPrettyName()) 190 198 ); 191 cachedActualValues.Value.Value = value; 192 199 CachedActualValue = value; 200 201 string translatedName = Name; 202 SetValue(ExecutionContext, ref translatedName, value); 203 } 204 205 protected static void SetValue(IExecutionContext executionContext, ref string name, IItem value) { 193 206 // try to set value in context stack 194 string name; 195 IValueParameter param = GetValueParameterAndTranslateName(out name); 207 IValueParameter param = GetValueParameterAndTranslateName(executionContext, ref name); 196 208 if (param != null) { 197 209 param.Value = value; … … 200 212 201 213 // try to set value in scope 202 IVariable var = LookupVariable( name);214 IVariable var = LookupVariable(executionContext.Scope, name); 203 215 if (var != null) { 204 216 var.Value = value; … … 207 219 208 220 // create new variable 209 ExecutionContext.Scope.Variables.Add(new Variable(name, value));221 executionContext.Scope.Variables.Add(new Variable(name, value)); 210 222 } 211 223 -
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/OperatorParameter.cs
r12012 r15973 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/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs
r12012 r15973 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/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs
r12012 r15973 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/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/Parameter.cs
r12012 r15973 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/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/Plugin.cs.frame
r13321 r15973 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/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/Properties/AssemblyInfo.cs.frame
r13321 r15973 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/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/ScopeParameter.cs
r12012 r15973 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/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/ScopeTreeLookupParameter.cs
r12012 r15973 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/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs
r12012 r15973 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/2522_RefactorPluginInfrastructure/HeuristicLab.Parameters/3.3/ValueParameter.cs
r12012 r15973 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.