Changeset 2818 for trunk/sources/HeuristicLab.Parameters
- Timestamp:
- 02/17/10 05:24:03 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Parameters/3.3
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Parameters/3.3/HeuristicLabParametersPlugin.cs.frame
r2790 r2818 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Text;25 22 using HeuristicLab.PluginInfrastructure; 26 23 -
trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs
r2805 r2818 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 using System.Xml;26 23 using HeuristicLab.Common; 27 24 using HeuristicLab.Core; … … 71 68 72 69 public override string ToString() { 73 return string.Format("{0}: {1} ({2})", Name, ActualName, DataType. Name);74 } 75 76 private IValueParameter <T>GetParameter(out string name) {77 IValueParameter <T> valueParam = this as IValueParameter<T>;78 ILookupParameter <T> lookupParam = this as ILookupParameter<T>;70 return string.Format("{0}: {1} ({2})", Name, ActualName, DataType.GetPrettyName()); 71 } 72 73 private IValueParameter GetParameter(out string name) { 74 IValueParameter valueParam = this as IValueParameter; 75 ILookupParameter lookupParam = this as ILookupParameter; 79 76 ExecutionContext current = ExecutionContext; 80 77 81 78 name = Name; 82 while ((valueParam != null) &&(lookupParam != null)) {79 while ((valueParam != null) || (lookupParam != null)) { 83 80 if ((valueParam != null) && (valueParam.Value != null)) return valueParam; 84 81 if (lookupParam != null) name = lookupParam.ActualName; … … 89 86 90 87 if (current != null) { 91 valueParam = current.Operator.Parameters[name] as IValueParameter <T>;92 lookupParam = current.Operator.Parameters[name] as ILookupParameter <T>;88 valueParam = current.Operator.Parameters[name] as IValueParameter; 89 lookupParam = current.Operator.Parameters[name] as ILookupParameter; 93 90 if ((valueParam == null) && (lookupParam == null)) 94 91 throw new InvalidOperationException( 95 92 string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\" or an \"{2}\".", 96 93 name, 97 typeof(IValueParameter <T>).GetPrettyName(),98 typeof(ILookupParameter <T>).GetPrettyName())94 typeof(IValueParameter).GetPrettyName(), 95 typeof(ILookupParameter).GetPrettyName()) 99 96 ); 100 97 } else { … … 111 108 return scope != null ? scope.Variables[actualName] : null; 112 109 } 113 private IValueParameter <T>GetProblemParameter(string name) {114 IValueParameter <T>param = null;110 private IValueParameter GetProblemParameter(string name) { 111 IValueParameter param = null; 115 112 if (ExecutionContext.Problem.Parameters.ContainsKey(name)) { 116 param = ExecutionContext.Problem.Parameters[name] as IValueParameter <T>;113 param = ExecutionContext.Problem.Parameters[name] as IValueParameter; 117 114 if (param == null) 118 115 throw new InvalidOperationException( 119 116 string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\".", 120 117 name, 121 typeof(IValueParameter <T>).GetPrettyName())118 typeof(IValueParameter).GetPrettyName()) 122 119 ); 123 120 } … … 127 124 string name; 128 125 // try to get value from context stack 129 IValueParameter <T>param = GetParameter(out name);126 IValueParameter param = GetParameter(out name); 130 127 if (param != null) return param.Value; 131 128 … … 144 141 145 142 // try to get value from problem 146 IValueParameter <T>problemParam = GetProblemParameter(name);143 IValueParameter problemParam = GetProblemParameter(name); 147 144 if (problemParam != null) return problemParam.Value; 148 145 … … 158 155 // try to set value in context stack 159 156 string name; 160 IValueParameter <T>param = GetParameter(out name);157 IValueParameter param = GetParameter(out name); 161 158 if (param != null) { 162 159 param.Value = val; … … 172 169 173 170 // try to set value in problem 174 IValueParameter <T>problemParam = GetProblemParameter(name);171 IValueParameter problemParam = GetProblemParameter(name); 175 172 if (problemParam != null) { 176 173 problemParam.Value = val; … … 193 190 ExecutionContext currentContext = context; 194 191 IParameter param; 195 ILookupParameter <T>lookupParam;192 ILookupParameter lookupParam; 196 193 197 194 while (currentContext != null) { 198 195 currentContext.Operator.Parameters.TryGetValue(currentName, out param); 199 196 if (param != null) { 200 lookupParam = param as ILookupParameter <T>;197 lookupParam = param as ILookupParameter; 201 198 if (lookupParam == null) 202 199 throw new InvalidOperationException( 203 200 string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\".", 204 201 currentName, 205 typeof(ILookupParameter <T>).GetPrettyName())202 typeof(ILookupParameter).GetPrettyName()) 206 203 ); 207 204 currentName = lookupParam.ActualName; -
trunk/sources/HeuristicLab.Parameters/3.3/OperatorParameter.cs
r2790 r2818 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Text;25 using System.Xml;26 22 using HeuristicLab.Core; 27 23 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; -
trunk/sources/HeuristicLab.Parameters/3.3/Parameter.cs
r2790 r2818 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Text; 25 using System.Xml; 23 using HeuristicLab.Common; 26 24 using HeuristicLab.Core; 27 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 84 82 85 83 public override string ToString() { 86 return string.Format("{0} ({1})", Name, DataType. Name);84 return string.Format("{0} ({1})", Name, DataType.GetPrettyName()); 87 85 } 88 86 -
trunk/sources/HeuristicLab.Parameters/3.3/ScopeParameter.cs
r2790 r2818 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Text; 25 using System.Xml; 23 using HeuristicLab.Common; 26 24 using HeuristicLab.Core; 27 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 50 48 51 49 public override string ToString() { 52 return string.Format("{0} ({1})", Name, DataType. Name);50 return string.Format("{0} ({1})", Name, DataType.GetPrettyName()); 53 51 } 54 52 -
trunk/sources/HeuristicLab.Parameters/3.3/SubScopesLookupParameter.cs
r2796 r2818 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 using System.Xml;26 23 using HeuristicLab.Common; 27 24 using HeuristicLab.Core; 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;29 25 30 26 namespace HeuristicLab.Parameters { … … 39 35 40 36 protected override IItem GetActualValue() { 41 string name = LookupParameter< T>.TranslateName(Name, ExecutionContext);37 string name = LookupParameter<ItemArray<T>>.TranslateName(Name, ExecutionContext); 42 38 IScope scope = ExecutionContext.Scope; 43 39 ItemArray<T> values = new ItemArray<T>(scope.SubScopes.Count); … … 68 64 ); 69 65 70 string name = LookupParameter< T>.TranslateName(Name, ExecutionContext);66 string name = LookupParameter<ItemArray<T>>.TranslateName(Name, ExecutionContext); 71 67 IScope scope = ExecutionContext.Scope; 72 68 IVariable var; -
trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs
r2796 r2818 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 using System.Xml;26 23 using HeuristicLab.Common; 27 24 using HeuristicLab.Core; … … 85 82 86 83 public override string ToString() { 87 return string.Format("{0}: {1} ({2})", Name, Value != null ? Value.ToString() : ActualName, DataType. Name);84 return string.Format("{0}: {1} ({2})", Name, Value != null ? Value.ToString() : ActualName, DataType.GetPrettyName()); 88 85 } 89 86 -
trunk/sources/HeuristicLab.Parameters/3.3/ValueParameter.cs
r2796 r2818 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 using System.Xml;26 23 using HeuristicLab.Common; 27 24 using HeuristicLab.Core; … … 85 82 86 83 public override string ToString() { 87 return string.Format("{0}: {1} ({2})", Name, Value != null ? Value.ToString() : "null", DataType. Name);84 return string.Format("{0}: {1} ({2})", Name, Value != null ? Value.ToString() : "null", DataType.GetPrettyName()); 88 85 } 89 86
Note: See TracChangeset
for help on using the changeset viewer.