aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/General/ConfigurationMember.cs
diff options
context:
space:
mode:
authorJeff Ames2007-10-31 01:21:04 +0000
committerJeff Ames2007-10-31 01:21:04 +0000
commit98b238cf6b75e9d26cf8f423decfbfd9df36b438 (patch)
tree553a190fec2f6e7492dd28129326929e3dbb3e15 /OpenSim/Framework/General/ConfigurationMember.cs
parentTevarus' patch for object flags & implemented Phantom edits (diff)
downloadopensim-SC_OLD-98b238cf6b75e9d26cf8f423decfbfd9df36b438.zip
opensim-SC_OLD-98b238cf6b75e9d26cf8f423decfbfd9df36b438.tar.gz
opensim-SC_OLD-98b238cf6b75e9d26cf8f423decfbfd9df36b438.tar.bz2
opensim-SC_OLD-98b238cf6b75e9d26cf8f423decfbfd9df36b438.tar.xz
set svn:eol-style
Diffstat (limited to 'OpenSim/Framework/General/ConfigurationMember.cs')
-rw-r--r--OpenSim/Framework/General/ConfigurationMember.cs878
1 files changed, 439 insertions, 439 deletions
diff --git a/OpenSim/Framework/General/ConfigurationMember.cs b/OpenSim/Framework/General/ConfigurationMember.cs
index 5883d73..b68896c 100644
--- a/OpenSim/Framework/General/ConfigurationMember.cs
+++ b/OpenSim/Framework/General/ConfigurationMember.cs
@@ -1,440 +1,440 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Globalization; 31using System.Globalization;
32using System.Net; 32using System.Net;
33using System.Reflection; 33using System.Reflection;
34using libsecondlife; 34using libsecondlife;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36 36
37namespace OpenSim.Framework 37namespace OpenSim.Framework
38{ 38{
39 public class ConfigurationMember 39 public class ConfigurationMember
40 { 40 {
41 public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result); 41 public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result);
42 42
43 public delegate void ConfigurationOptionsLoad(); 43 public delegate void ConfigurationOptionsLoad();
44 44
45 private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>(); 45 private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>();
46 private string configurationFilename = ""; 46 private string configurationFilename = "";
47 private string configurationDescription = ""; 47 private string configurationDescription = "";
48 48
49 private ConfigurationOptionsLoad loadFunction; 49 private ConfigurationOptionsLoad loadFunction;
50 private ConfigurationOptionResult resultFunction; 50 private ConfigurationOptionResult resultFunction;
51 51
52 private IGenericConfig configurationPlugin = null; 52 private IGenericConfig configurationPlugin = null;
53 53
54 /// <summary> 54 /// <summary>
55 /// This is the default configuration DLL loaded 55 /// This is the default configuration DLL loaded
56 /// </summary> 56 /// </summary>
57 private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll"; 57 private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll";
58 58
59 public ConfigurationMember(string configuration_filename, string configuration_description, 59 public ConfigurationMember(string configuration_filename, string configuration_description,
60 ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) 60 ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function)
61 { 61 {
62 configurationFilename = configuration_filename; 62 configurationFilename = configuration_filename;
63 configurationDescription = configuration_description; 63 configurationDescription = configuration_description;
64 loadFunction = load_function; 64 loadFunction = load_function;
65 resultFunction = result_function; 65 resultFunction = result_function;
66 } 66 }
67 67
68 public void setConfigurationFilename(string filename) 68 public void setConfigurationFilename(string filename)
69 { 69 {
70 configurationFilename = filename; 70 configurationFilename = filename;
71 } 71 }
72 72
73 public void setConfigurationDescription(string desc) 73 public void setConfigurationDescription(string desc)
74 { 74 {
75 configurationDescription = desc; 75 configurationDescription = desc;
76 } 76 }
77 77
78 public void setConfigurationResultFunction(ConfigurationOptionResult result) 78 public void setConfigurationResultFunction(ConfigurationOptionResult result)
79 { 79 {
80 resultFunction = result; 80 resultFunction = result;
81 } 81 }
82 82
83 public void forceConfigurationPluginLibrary(string dll_filename) 83 public void forceConfigurationPluginLibrary(string dll_filename)
84 { 84 {
85 configurationPluginFilename = dll_filename; 85 configurationPluginFilename = dll_filename;
86 } 86 }
87 87
88 public void addConfigurationOption(string configuration_key, 88 public void addConfigurationOption(string configuration_key,
89 ConfigurationOption.ConfigurationTypes configuration_type, 89 ConfigurationOption.ConfigurationTypes configuration_type,
90 string configuration_question, string configuration_default, 90 string configuration_question, string configuration_default,
91 bool use_default_no_prompt) 91 bool use_default_no_prompt)
92 { 92 {
93 ConfigurationOption configOption = new ConfigurationOption(); 93 ConfigurationOption configOption = new ConfigurationOption();
94 configOption.configurationKey = configuration_key; 94 configOption.configurationKey = configuration_key;
95 configOption.configurationQuestion = configuration_question; 95 configOption.configurationQuestion = configuration_question;
96 configOption.configurationDefault = configuration_default; 96 configOption.configurationDefault = configuration_default;
97 configOption.configurationType = configuration_type; 97 configOption.configurationType = configuration_type;
98 configOption.configurationUseDefaultNoPrompt = use_default_no_prompt; 98 configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
99 99
100 if ((configuration_key != "" && configuration_question != "") || 100 if ((configuration_key != "" && configuration_question != "") ||
101 (configuration_key != "" && use_default_no_prompt)) 101 (configuration_key != "" && use_default_no_prompt))
102 { 102 {
103 if (!configurationOptions.Contains(configOption)) 103 if (!configurationOptions.Contains(configOption))
104 { 104 {
105 configurationOptions.Add(configOption); 105 configurationOptions.Add(configOption);
106 } 106 }
107 } 107 }
108 else 108 else
109 { 109 {
110 MainLog.Instance.Notice( 110 MainLog.Instance.Notice(
111 "Required fields for adding a configuration option is invalid. Will not add this option (" + 111 "Required fields for adding a configuration option is invalid. Will not add this option (" +
112 configuration_key + ")"); 112 configuration_key + ")");
113 } 113 }
114 } 114 }
115 115
116 public void performConfigurationRetrieve() 116 public void performConfigurationRetrieve()
117 { 117 {
118 configurationPlugin = LoadConfigDll(configurationPluginFilename); 118 configurationPlugin = LoadConfigDll(configurationPluginFilename);
119 configurationOptions.Clear(); 119 configurationOptions.Clear();
120 if (loadFunction == null) 120 if (loadFunction == null)
121 { 121 {
122 MainLog.Instance.Error("Load Function for '" + configurationDescription + 122 MainLog.Instance.Error("Load Function for '" + configurationDescription +
123 "' is null. Refusing to run configuration."); 123 "' is null. Refusing to run configuration.");
124 return; 124 return;
125 } 125 }
126 126
127 if (resultFunction == null) 127 if (resultFunction == null)
128 { 128 {
129 MainLog.Instance.Error("Result Function for '" + configurationDescription + 129 MainLog.Instance.Error("Result Function for '" + configurationDescription +
130 "' is null. Refusing to run configuration."); 130 "' is null. Refusing to run configuration.");
131 return; 131 return;
132 } 132 }
133 133
134 MainLog.Instance.Verbose("Calling Configuration Load Function..."); 134 MainLog.Instance.Verbose("Calling Configuration Load Function...");
135 loadFunction(); 135 loadFunction();
136 136
137 if (configurationOptions.Count <= 0) 137 if (configurationOptions.Count <= 0)
138 { 138 {
139 MainLog.Instance.Error("No configuration options were specified for '" + configurationOptions + 139 MainLog.Instance.Error("No configuration options were specified for '" + configurationOptions +
140 "'. Refusing to continue configuration."); 140 "'. Refusing to continue configuration.");
141 return; 141 return;
142 } 142 }
143 143
144 bool useFile = true; 144 bool useFile = true;
145 if (configurationPlugin == null) 145 if (configurationPlugin == null)
146 { 146 {
147 MainLog.Instance.Error("Configuration Plugin NOT LOADED!"); 147 MainLog.Instance.Error("Configuration Plugin NOT LOADED!");
148 return; 148 return;
149 } 149 }
150 150
151 if (configurationFilename.Trim() != "") 151 if (configurationFilename.Trim() != "")
152 { 152 {
153 configurationPlugin.SetFileName(configurationFilename); 153 configurationPlugin.SetFileName(configurationFilename);
154 configurationPlugin.LoadData(); 154 configurationPlugin.LoadData();
155 useFile = true; 155 useFile = true;
156 } 156 }
157 else 157 else
158 { 158 {
159 MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file."); 159 MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file.");
160 useFile = false; 160 useFile = false;
161 } 161 }
162 162
163 foreach (ConfigurationOption configOption in configurationOptions) 163 foreach (ConfigurationOption configOption in configurationOptions)
164 { 164 {
165 bool convertSuccess = false; 165 bool convertSuccess = false;
166 object return_result = null; 166 object return_result = null;
167 string errorMessage = ""; 167 string errorMessage = "";
168 bool ignoreNextFromConfig = false; 168 bool ignoreNextFromConfig = false;
169 while (convertSuccess == false) 169 while (convertSuccess == false)
170 { 170 {
171 string console_result = ""; 171 string console_result = "";
172 string attribute = null; 172 string attribute = null;
173 if (useFile) 173 if (useFile)
174 { 174 {
175 if (!ignoreNextFromConfig) 175 if (!ignoreNextFromConfig)
176 { 176 {
177 attribute = configurationPlugin.GetAttribute(configOption.configurationKey); 177 attribute = configurationPlugin.GetAttribute(configOption.configurationKey);
178 } 178 }
179 else 179 else
180 { 180 {
181 ignoreNextFromConfig = false; 181 ignoreNextFromConfig = false;
182 } 182 }
183 } 183 }
184 184
185 if (attribute == null) 185 if (attribute == null)
186 { 186 {
187 if (configOption.configurationUseDefaultNoPrompt) 187 if (configOption.configurationUseDefaultNoPrompt)
188 { 188 {
189 console_result = configOption.configurationDefault; 189 console_result = configOption.configurationDefault;
190 } 190 }
191 else 191 else
192 { 192 {
193 if (configurationDescription.Trim() != "") 193 if (configurationDescription.Trim() != "")
194 { 194 {
195 console_result = 195 console_result =
196 MainLog.Instance.CmdPrompt( 196 MainLog.Instance.CmdPrompt(
197 configurationDescription + ": " + configOption.configurationQuestion, 197 configurationDescription + ": " + configOption.configurationQuestion,
198 configOption.configurationDefault); 198 configOption.configurationDefault);
199 } 199 }
200 else 200 else
201 { 201 {
202 console_result = 202 console_result =
203 MainLog.Instance.CmdPrompt(configOption.configurationQuestion, 203 MainLog.Instance.CmdPrompt(configOption.configurationQuestion,
204 configOption.configurationDefault); 204 configOption.configurationDefault);
205 } 205 }
206 } 206 }
207 } 207 }
208 else 208 else
209 { 209 {
210 console_result = attribute; 210 console_result = attribute;
211 } 211 }
212 212
213 switch (configOption.configurationType) 213 switch (configOption.configurationType)
214 { 214 {
215 case ConfigurationOption.ConfigurationTypes.TYPE_STRING: 215 case ConfigurationOption.ConfigurationTypes.TYPE_STRING:
216 return_result = console_result; 216 return_result = console_result;
217 convertSuccess = true; 217 convertSuccess = true;
218 break; 218 break;
219 case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY: 219 case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY:
220 if (console_result.Length > 0) 220 if (console_result.Length > 0)
221 { 221 {
222 return_result = console_result; 222 return_result = console_result;
223 convertSuccess = true; 223 convertSuccess = true;
224 } 224 }
225 errorMessage = "a string that is not empty"; 225 errorMessage = "a string that is not empty";
226 break; 226 break;
227 case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN: 227 case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN:
228 bool boolResult; 228 bool boolResult;
229 if (Boolean.TryParse(console_result, out boolResult)) 229 if (Boolean.TryParse(console_result, out boolResult))
230 { 230 {
231 convertSuccess = true; 231 convertSuccess = true;
232 return_result = boolResult; 232 return_result = boolResult;
233 } 233 }
234 errorMessage = "'true' or 'false' (Boolean)"; 234 errorMessage = "'true' or 'false' (Boolean)";
235 break; 235 break;
236 case ConfigurationOption.ConfigurationTypes.TYPE_BYTE: 236 case ConfigurationOption.ConfigurationTypes.TYPE_BYTE:
237 byte byteResult; 237 byte byteResult;
238 if (Byte.TryParse(console_result, out byteResult)) 238 if (Byte.TryParse(console_result, out byteResult))
239 { 239 {
240 convertSuccess = true; 240 convertSuccess = true;
241 return_result = byteResult; 241 return_result = byteResult;
242 } 242 }
243 errorMessage = "a byte (Byte)"; 243 errorMessage = "a byte (Byte)";
244 break; 244 break;
245 case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER: 245 case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER:
246 char charResult; 246 char charResult;
247 if (Char.TryParse(console_result, out charResult)) 247 if (Char.TryParse(console_result, out charResult))
248 { 248 {
249 convertSuccess = true; 249 convertSuccess = true;
250 return_result = charResult; 250 return_result = charResult;
251 } 251 }
252 errorMessage = "a character (Char)"; 252 errorMessage = "a character (Char)";
253 break; 253 break;
254 case ConfigurationOption.ConfigurationTypes.TYPE_INT16: 254 case ConfigurationOption.ConfigurationTypes.TYPE_INT16:
255 short shortResult; 255 short shortResult;
256 if (Int16.TryParse(console_result, out shortResult)) 256 if (Int16.TryParse(console_result, out shortResult))
257 { 257 {
258 convertSuccess = true; 258 convertSuccess = true;
259 return_result = shortResult; 259 return_result = shortResult;
260 } 260 }
261 errorMessage = "a signed 32 bit integer (short)"; 261 errorMessage = "a signed 32 bit integer (short)";
262 break; 262 break;
263 case ConfigurationOption.ConfigurationTypes.TYPE_INT32: 263 case ConfigurationOption.ConfigurationTypes.TYPE_INT32:
264 int intResult; 264 int intResult;
265 if (Int32.TryParse(console_result, out intResult)) 265 if (Int32.TryParse(console_result, out intResult))
266 { 266 {
267 convertSuccess = true; 267 convertSuccess = true;
268 return_result = intResult; 268 return_result = intResult;
269 } 269 }
270 errorMessage = "a signed 32 bit integer (int)"; 270 errorMessage = "a signed 32 bit integer (int)";
271 break; 271 break;
272 case ConfigurationOption.ConfigurationTypes.TYPE_INT64: 272 case ConfigurationOption.ConfigurationTypes.TYPE_INT64:
273 long longResult; 273 long longResult;
274 if (Int64.TryParse(console_result, out longResult)) 274 if (Int64.TryParse(console_result, out longResult))
275 { 275 {
276 convertSuccess = true; 276 convertSuccess = true;
277 return_result = longResult; 277 return_result = longResult;
278 } 278 }
279 errorMessage = "a signed 32 bit integer (long)"; 279 errorMessage = "a signed 32 bit integer (long)";
280 break; 280 break;
281 case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS: 281 case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS:
282 IPAddress ipAddressResult; 282 IPAddress ipAddressResult;
283 if (IPAddress.TryParse(console_result, out ipAddressResult)) 283 if (IPAddress.TryParse(console_result, out ipAddressResult))
284 { 284 {
285 convertSuccess = true; 285 convertSuccess = true;
286 return_result = ipAddressResult; 286 return_result = ipAddressResult;
287 } 287 }
288 errorMessage = "an IP Address (IPAddress)"; 288 errorMessage = "an IP Address (IPAddress)";
289 break; 289 break;
290 case ConfigurationOption.ConfigurationTypes.TYPE_LLUUID: 290 case ConfigurationOption.ConfigurationTypes.TYPE_LLUUID:
291 LLUUID uuidResult; 291 LLUUID uuidResult;
292 if (LLUUID.TryParse(console_result, out uuidResult)) 292 if (LLUUID.TryParse(console_result, out uuidResult))
293 { 293 {
294 convertSuccess = true; 294 convertSuccess = true;
295 return_result = uuidResult; 295 return_result = uuidResult;
296 } 296 }
297 errorMessage = "a UUID (LLUUID)"; 297 errorMessage = "a UUID (LLUUID)";
298 break; 298 break;
299 case ConfigurationOption.ConfigurationTypes.TYPE_LLVECTOR3: 299 case ConfigurationOption.ConfigurationTypes.TYPE_LLVECTOR3:
300 LLVector3 vectorResult; 300 LLVector3 vectorResult;
301 if (LLVector3.TryParse(console_result, out vectorResult)) 301 if (LLVector3.TryParse(console_result, out vectorResult))
302 { 302 {
303 convertSuccess = true; 303 convertSuccess = true;
304 return_result = vectorResult; 304 return_result = vectorResult;
305 } 305 }
306 errorMessage = "a vector (LLVector3)"; 306 errorMessage = "a vector (LLVector3)";
307 break; 307 break;
308 case ConfigurationOption.ConfigurationTypes.TYPE_UINT16: 308 case ConfigurationOption.ConfigurationTypes.TYPE_UINT16:
309 ushort ushortResult; 309 ushort ushortResult;
310 if (UInt16.TryParse(console_result, out ushortResult)) 310 if (UInt16.TryParse(console_result, out ushortResult))
311 { 311 {
312 convertSuccess = true; 312 convertSuccess = true;
313 return_result = ushortResult; 313 return_result = ushortResult;
314 } 314 }
315 errorMessage = "an unsigned 16 bit integer (ushort)"; 315 errorMessage = "an unsigned 16 bit integer (ushort)";
316 break; 316 break;
317 case ConfigurationOption.ConfigurationTypes.TYPE_UINT32: 317 case ConfigurationOption.ConfigurationTypes.TYPE_UINT32:
318 uint uintResult; 318 uint uintResult;
319 if (UInt32.TryParse(console_result, out uintResult)) 319 if (UInt32.TryParse(console_result, out uintResult))
320 { 320 {
321 convertSuccess = true; 321 convertSuccess = true;
322 return_result = uintResult; 322 return_result = uintResult;
323 } 323 }
324 errorMessage = "an unsigned 32 bit integer (uint)"; 324 errorMessage = "an unsigned 32 bit integer (uint)";
325 break; 325 break;
326 case ConfigurationOption.ConfigurationTypes.TYPE_UINT64: 326 case ConfigurationOption.ConfigurationTypes.TYPE_UINT64:
327 ulong ulongResult; 327 ulong ulongResult;
328 if (UInt64.TryParse(console_result, out ulongResult)) 328 if (UInt64.TryParse(console_result, out ulongResult))
329 { 329 {
330 convertSuccess = true; 330 convertSuccess = true;
331 return_result = ulongResult; 331 return_result = ulongResult;
332 } 332 }
333 errorMessage = "an unsigned 64 bit integer (ulong)"; 333 errorMessage = "an unsigned 64 bit integer (ulong)";
334 break; 334 break;
335 case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT: 335 case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT:
336 float floatResult; 336 float floatResult;
337 if ( 337 if (
338 float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, 338 float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo,
339 out floatResult)) 339 out floatResult))
340 { 340 {
341 convertSuccess = true; 341 convertSuccess = true;
342 return_result = floatResult; 342 return_result = floatResult;
343 } 343 }
344 errorMessage = "a single-precision floating point number (float)"; 344 errorMessage = "a single-precision floating point number (float)";
345 break; 345 break;
346 case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE: 346 case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE:
347 double doubleResult; 347 double doubleResult;
348 if ( 348 if (
349 Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, 349 Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo,
350 out doubleResult)) 350 out doubleResult))
351 { 351 {
352 convertSuccess = true; 352 convertSuccess = true;
353 return_result = doubleResult; 353 return_result = doubleResult;
354 } 354 }
355 errorMessage = "an double-precision floating point number (double)"; 355 errorMessage = "an double-precision floating point number (double)";
356 break; 356 break;
357 } 357 }
358 358
359 if (convertSuccess) 359 if (convertSuccess)
360 { 360 {
361 if (useFile) 361 if (useFile)
362 { 362 {
363 configurationPlugin.SetAttribute(configOption.configurationKey, console_result); 363 configurationPlugin.SetAttribute(configOption.configurationKey, console_result);
364 } 364 }
365 365
366 366
367 if (!resultFunction(configOption.configurationKey, return_result)) 367 if (!resultFunction(configOption.configurationKey, return_result))
368 { 368 {
369 MainLog.Instance.Notice( 369 MainLog.Instance.Notice(
370 "The handler for the last configuration option denied that input, please try again."); 370 "The handler for the last configuration option denied that input, please try again.");
371 convertSuccess = false; 371 convertSuccess = false;
372 ignoreNextFromConfig = true; 372 ignoreNextFromConfig = true;
373 } 373 }
374 } 374 }
375 else 375 else
376 { 376 {
377 if (configOption.configurationUseDefaultNoPrompt) 377 if (configOption.configurationUseDefaultNoPrompt)
378 { 378 {
379 MainLog.Instance.Error("CONFIG", 379 MainLog.Instance.Error("CONFIG",
380 string.Format( 380 string.Format(
381 "[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", 381 "[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n",
382 configOption.configurationKey, console_result, errorMessage, 382 configOption.configurationKey, console_result, errorMessage,
383 configurationFilename)); 383 configurationFilename));
384 convertSuccess = true; 384 convertSuccess = true;
385 } 385 }
386 else 386 else
387 { 387 {
388 MainLog.Instance.Warn("CONFIG", 388 MainLog.Instance.Warn("CONFIG",
389 string.Format( 389 string.Format(
390 "[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", 390 "[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n",
391 configOption.configurationKey, console_result, errorMessage, 391 configOption.configurationKey, console_result, errorMessage,
392 configurationFilename)); 392 configurationFilename));
393 ignoreNextFromConfig = true; 393 ignoreNextFromConfig = true;
394 } 394 }
395 } 395 }
396 } 396 }
397 } 397 }
398 398
399 if (useFile) 399 if (useFile)
400 { 400 {
401 configurationPlugin.Commit(); 401 configurationPlugin.Commit();
402 configurationPlugin.Close(); 402 configurationPlugin.Close();
403 } 403 }
404 } 404 }
405 405
406 private IGenericConfig LoadConfigDll(string dllName) 406 private IGenericConfig LoadConfigDll(string dllName)
407 { 407 {
408 Assembly pluginAssembly = Assembly.LoadFrom(dllName); 408 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
409 IGenericConfig plug = null; 409 IGenericConfig plug = null;
410 410
411 foreach (Type pluginType in pluginAssembly.GetTypes()) 411 foreach (Type pluginType in pluginAssembly.GetTypes())
412 { 412 {
413 if (pluginType.IsPublic) 413 if (pluginType.IsPublic)
414 { 414 {
415 if (!pluginType.IsAbstract) 415 if (!pluginType.IsAbstract)
416 { 416 {
417 Type typeInterface = pluginType.GetInterface("IGenericConfig", true); 417 Type typeInterface = pluginType.GetInterface("IGenericConfig", true);
418 418
419 if (typeInterface != null) 419 if (typeInterface != null)
420 { 420 {
421 plug = 421 plug =
422 (IGenericConfig) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 422 (IGenericConfig) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
423 } 423 }
424 } 424 }
425 } 425 }
426 } 426 }
427 427
428 pluginAssembly = null; 428 pluginAssembly = null;
429 return plug; 429 return plug;
430 } 430 }
431 431
432 public void forceSetConfigurationOption(string configuration_key, string configuration_value) 432 public void forceSetConfigurationOption(string configuration_key, string configuration_value)
433 { 433 {
434 configurationPlugin.LoadData(); 434 configurationPlugin.LoadData();
435 configurationPlugin.SetAttribute(configuration_key, configuration_value); 435 configurationPlugin.SetAttribute(configuration_key, configuration_value);
436 configurationPlugin.Commit(); 436 configurationPlugin.Commit();
437 configurationPlugin.Close(); 437 configurationPlugin.Close();
438 } 438 }
439 } 439 }
440} \ No newline at end of file 440} \ No newline at end of file