aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/General/ConfigurationMember.cs
diff options
context:
space:
mode:
authorMW2007-10-29 21:46:25 +0000
committerMW2007-10-29 21:46:25 +0000
commit3d8219f6c7faa256d6a13ab7925f75d83af95b78 (patch)
treeea507efa88aa7e526575469a6ce913fdc0c0358e /OpenSim/Framework/General/ConfigurationMember.cs
parentFixed a bug in SQLAssetServer that only seemed to be a problem when running u... (diff)
downloadopensim-SC-3d8219f6c7faa256d6a13ab7925f75d83af95b78.zip
opensim-SC-3d8219f6c7faa256d6a13ab7925f75d83af95b78.tar.gz
opensim-SC-3d8219f6c7faa256d6a13ab7925f75d83af95b78.tar.bz2
opensim-SC-3d8219f6c7faa256d6a13ab7925f75d83af95b78.tar.xz
as per the "Filesystem cleanup for OpenSim repository" mailing list thread. Have flattened the OpenSim.Framework project/namespace. The problem is that the namespace is still wrong as its "OpenSim.Framework" while the directory is "OpenSim\Framework\General" , so we need to decide if we change the directory or correct the namespace.
Note this has lead to a big flat project, but I think a lot of the files we most likely don't even use any longer. And others belong in other projects/namespaces anyway.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/General/ConfigurationMember.cs (renamed from OpenSim/Framework/General/Configuration/ConfigurationMember.cs)829
1 files changed, 414 insertions, 415 deletions
diff --git a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs b/OpenSim/Framework/General/ConfigurationMember.cs
index af9a0f6..c71982a 100644
--- a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs
+++ b/OpenSim/Framework/General/ConfigurationMember.cs
@@ -1,415 +1,414 @@
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.Reflection; 30using System.Reflection;
31using System.Collections; 31using System.Collections;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using System.Text; 33using System.Text;
34using System.Net; 34using System.Net;
35 35
36using libsecondlife; 36using libsecondlife;
37 37
38using OpenSim.Framework.Console; 38using OpenSim.Framework.Console;
39using OpenSim.Framework.Configuration.Interfaces; 39using System.Globalization;
40using System.Globalization; 40
41 41namespace OpenSim.Framework
42namespace OpenSim.Framework.Configuration 42{
43{ 43 public class ConfigurationMember
44 public class ConfigurationMember 44 {
45 { 45 public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result);
46 public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result); 46 public delegate void ConfigurationOptionsLoad();
47 public delegate void ConfigurationOptionsLoad(); 47
48 48 private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>();
49 private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>(); 49 private string configurationFilename = "";
50 private string configurationFilename = ""; 50 private string configurationDescription = "";
51 private string configurationDescription = ""; 51
52 52 private ConfigurationOptionsLoad loadFunction;
53 private ConfigurationOptionsLoad loadFunction; 53 private ConfigurationOptionResult resultFunction;
54 private ConfigurationOptionResult resultFunction; 54
55 55 private IGenericConfig configurationPlugin = null;
56 private IGenericConfig configurationPlugin = null; 56 /// <summary>
57 /// <summary> 57 /// This is the default configuration DLL loaded
58 /// This is the default configuration DLL loaded 58 /// </summary>
59 /// </summary> 59 private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll";
60 private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll"; 60 public ConfigurationMember(string configuration_filename, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function)
61 public ConfigurationMember(string configuration_filename, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) 61 {
62 { 62 this.configurationFilename = configuration_filename;
63 this.configurationFilename = configuration_filename; 63 this.configurationDescription = configuration_description;
64 this.configurationDescription = configuration_description; 64 this.loadFunction = load_function;
65 this.loadFunction = load_function; 65 this.resultFunction = result_function;
66 this.resultFunction = result_function; 66 }
67 } 67
68 68 public void setConfigurationFilename(string filename)
69 public void setConfigurationFilename(string filename) 69 {
70 { 70 configurationFilename = filename;
71 configurationFilename = filename; 71 }
72 } 72 public void setConfigurationDescription(string desc)
73 public void setConfigurationDescription(string desc) 73 {
74 { 74 configurationDescription = desc;
75 configurationDescription = desc; 75 }
76 } 76
77 77 public void setConfigurationResultFunction(ConfigurationOptionResult result)
78 public void setConfigurationResultFunction(ConfigurationOptionResult result) 78 {
79 { 79 resultFunction = result;
80 resultFunction = result; 80 }
81 } 81
82 82 public void forceConfigurationPluginLibrary(string dll_filename)
83 public void forceConfigurationPluginLibrary(string dll_filename) 83 {
84 { 84 configurationPluginFilename = dll_filename;
85 configurationPluginFilename = dll_filename; 85 }
86 } 86 public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt)
87 public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt) 87 {
88 { 88 ConfigurationOption configOption = new ConfigurationOption();
89 ConfigurationOption configOption = new ConfigurationOption(); 89 configOption.configurationKey = configuration_key;
90 configOption.configurationKey = configuration_key; 90 configOption.configurationQuestion = configuration_question;
91 configOption.configurationQuestion = configuration_question; 91 configOption.configurationDefault = configuration_default;
92 configOption.configurationDefault = configuration_default; 92 configOption.configurationType = configuration_type;
93 configOption.configurationType = configuration_type; 93 configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
94 configOption.configurationUseDefaultNoPrompt = use_default_no_prompt; 94
95 95 if ((configuration_key != "" && configuration_question != "") || (configuration_key != "" && use_default_no_prompt))
96 if ((configuration_key != "" && configuration_question != "") || (configuration_key != "" && use_default_no_prompt)) 96 {
97 { 97 if (!configurationOptions.Contains(configOption))
98 if (!configurationOptions.Contains(configOption)) 98 {
99 { 99 configurationOptions.Add(configOption);
100 configurationOptions.Add(configOption); 100 }
101 } 101 }
102 } 102 else
103 else 103 {
104 { 104 MainLog.Instance.Notice("Required fields for adding a configuration option is invalid. Will not add this option (" + configuration_key + ")");
105 MainLog.Instance.Notice("Required fields for adding a configuration option is invalid. Will not add this option (" + configuration_key + ")"); 105 }
106 } 106 }
107 } 107
108 108 public void performConfigurationRetrieve()
109 public void performConfigurationRetrieve() 109 {
110 { 110 configurationPlugin = this.LoadConfigDll(configurationPluginFilename);
111 configurationPlugin = this.LoadConfigDll(configurationPluginFilename); 111 configurationOptions.Clear();
112 configurationOptions.Clear(); 112 if(loadFunction == null)
113 if(loadFunction == null) 113 {
114 { 114 MainLog.Instance.Error("Load Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
115 MainLog.Instance.Error("Load Function for '" + this.configurationDescription + "' is null. Refusing to run configuration."); 115 return;
116 return; 116 }
117 } 117
118 118 if(resultFunction == null)
119 if(resultFunction == null) 119 {
120 { 120 MainLog.Instance.Error("Result Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
121 MainLog.Instance.Error("Result Function for '" + this.configurationDescription + "' is null. Refusing to run configuration."); 121 return;
122 return; 122 }
123 } 123
124 124 MainLog.Instance.Verbose("Calling Configuration Load Function...");
125 MainLog.Instance.Verbose("Calling Configuration Load Function..."); 125 this.loadFunction();
126 this.loadFunction(); 126
127 127 if(configurationOptions.Count <= 0)
128 if(configurationOptions.Count <= 0) 128 {
129 { 129 MainLog.Instance.Error("No configuration options were specified for '" + this.configurationOptions + "'. Refusing to continue configuration.");
130 MainLog.Instance.Error("No configuration options were specified for '" + this.configurationOptions + "'. Refusing to continue configuration."); 130 return;
131 return; 131 }
132 } 132
133 133 bool useFile = true;
134 bool useFile = true; 134 if (configurationPlugin == null)
135 if (configurationPlugin == null) 135 {
136 { 136 MainLog.Instance.Error("Configuration Plugin NOT LOADED!");
137 MainLog.Instance.Error("Configuration Plugin NOT LOADED!"); 137 return;
138 return; 138 }
139 } 139
140 140 if (configurationFilename.Trim() != "")
141 if (configurationFilename.Trim() != "") 141 {
142 { 142 configurationPlugin.SetFileName(configurationFilename);
143 configurationPlugin.SetFileName(configurationFilename); 143 configurationPlugin.LoadData();
144 configurationPlugin.LoadData(); 144 useFile = true;
145 useFile = true; 145 }
146 } 146 else
147 else 147 {
148 { 148 MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file.");
149 MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file."); 149 useFile = false;
150 useFile = false; 150 }
151 } 151
152 152 foreach (ConfigurationOption configOption in configurationOptions)
153 foreach (ConfigurationOption configOption in configurationOptions) 153 {
154 { 154 bool convertSuccess = false;
155 bool convertSuccess = false; 155 object return_result = null;
156 object return_result = null; 156 string errorMessage = "";
157 string errorMessage = ""; 157 bool ignoreNextFromConfig = false;
158 bool ignoreNextFromConfig = false; 158 while (convertSuccess == false)
159 while (convertSuccess == false) 159 {
160 { 160
161 161 string console_result = "";
162 string console_result = ""; 162 string attribute = null;
163 string attribute = null; 163 if (useFile)
164 if (useFile) 164 {
165 { 165 if (!ignoreNextFromConfig)
166 if (!ignoreNextFromConfig) 166 {
167 { 167 attribute = configurationPlugin.GetAttribute(configOption.configurationKey);
168 attribute = configurationPlugin.GetAttribute(configOption.configurationKey); 168 }
169 } 169 else
170 else 170 {
171 { 171 ignoreNextFromConfig = false;
172 ignoreNextFromConfig = false; 172 }
173 } 173 }
174 } 174
175 175 if (attribute == null)
176 if (attribute == null) 176 {
177 { 177 if (configOption.configurationUseDefaultNoPrompt)
178 if (configOption.configurationUseDefaultNoPrompt) 178 {
179 { 179 console_result = configOption.configurationDefault;
180 console_result = configOption.configurationDefault; 180 }
181 } 181 else
182 else 182 {
183 { 183
184 184 if (configurationDescription.Trim() != "")
185 if (configurationDescription.Trim() != "") 185 {
186 { 186 console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault);
187 console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault); 187 }
188 } 188 else
189 else 189 {
190 { 190 console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault);
191 console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault); 191 }
192 } 192 }
193 } 193 }
194 } 194 else
195 else 195 {
196 { 196 console_result = attribute;
197 console_result = attribute; 197 }
198 } 198
199 199 switch (configOption.configurationType)
200 switch (configOption.configurationType) 200 {
201 { 201 case ConfigurationOption.ConfigurationTypes.TYPE_STRING:
202 case ConfigurationOption.ConfigurationTypes.TYPE_STRING: 202 return_result = console_result;
203 return_result = console_result; 203 convertSuccess = true;
204 convertSuccess = true; 204 break;
205 break; 205 case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY:
206 case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY: 206 if (console_result.Length > 0)
207 if (console_result.Length > 0) 207 {
208 { 208 return_result = console_result;
209 return_result = console_result; 209 convertSuccess = true;
210 convertSuccess = true; 210 }
211 } 211 errorMessage = "a string that is not empty";
212 errorMessage = "a string that is not empty"; 212 break;
213 break; 213 case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN:
214 case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN: 214 bool boolResult;
215 bool boolResult; 215 if (Boolean.TryParse(console_result, out boolResult))
216 if (Boolean.TryParse(console_result, out boolResult)) 216 {
217 { 217 convertSuccess = true;
218 convertSuccess = true; 218 return_result = boolResult;
219 return_result = boolResult; 219 }
220 } 220 errorMessage = "'true' or 'false' (Boolean)";
221 errorMessage = "'true' or 'false' (Boolean)"; 221 break;
222 break; 222 case ConfigurationOption.ConfigurationTypes.TYPE_BYTE:
223 case ConfigurationOption.ConfigurationTypes.TYPE_BYTE: 223 byte byteResult;
224 byte byteResult; 224 if (Byte.TryParse(console_result, out byteResult))
225 if (Byte.TryParse(console_result, out byteResult)) 225 {
226 { 226 convertSuccess = true;
227 convertSuccess = true; 227 return_result = byteResult;
228 return_result = byteResult; 228 }
229 } 229 errorMessage = "a byte (Byte)";
230 errorMessage = "a byte (Byte)"; 230 break;
231 break; 231 case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER:
232 case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER: 232 char charResult;
233 char charResult; 233 if (Char.TryParse(console_result, out charResult))
234 if (Char.TryParse(console_result, out charResult)) 234 {
235 { 235 convertSuccess = true;
236 convertSuccess = true; 236 return_result = charResult;
237 return_result = charResult; 237 }
238 } 238 errorMessage = "a character (Char)";
239 errorMessage = "a character (Char)"; 239 break;
240 break; 240 case ConfigurationOption.ConfigurationTypes.TYPE_INT16:
241 case ConfigurationOption.ConfigurationTypes.TYPE_INT16: 241 short shortResult;
242 short shortResult; 242 if (Int16.TryParse(console_result, out shortResult))
243 if (Int16.TryParse(console_result, out shortResult)) 243 {
244 { 244 convertSuccess = true;
245 convertSuccess = true; 245 return_result = shortResult;
246 return_result = shortResult; 246 }
247 } 247 errorMessage = "a signed 32 bit integer (short)";
248 errorMessage = "a signed 32 bit integer (short)"; 248 break;
249 break; 249 case ConfigurationOption.ConfigurationTypes.TYPE_INT32:
250 case ConfigurationOption.ConfigurationTypes.TYPE_INT32: 250 int intResult;
251 int intResult; 251 if (Int32.TryParse(console_result, out intResult))
252 if (Int32.TryParse(console_result, out intResult)) 252 {
253 { 253 convertSuccess = true;
254 convertSuccess = true; 254 return_result = intResult;
255 return_result = intResult; 255
256 256 }
257 } 257 errorMessage = "a signed 32 bit integer (int)";
258 errorMessage = "a signed 32 bit integer (int)"; 258 break;
259 break; 259 case ConfigurationOption.ConfigurationTypes.TYPE_INT64:
260 case ConfigurationOption.ConfigurationTypes.TYPE_INT64: 260 long longResult;
261 long longResult; 261 if (Int64.TryParse(console_result, out longResult))
262 if (Int64.TryParse(console_result, out longResult)) 262 {
263 { 263 convertSuccess = true;
264 convertSuccess = true; 264 return_result = longResult;
265 return_result = longResult; 265 }
266 } 266 errorMessage = "a signed 32 bit integer (long)";
267 errorMessage = "a signed 32 bit integer (long)"; 267 break;
268 break; 268 case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS:
269 case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS: 269 IPAddress ipAddressResult;
270 IPAddress ipAddressResult; 270 if (IPAddress.TryParse(console_result, out ipAddressResult))
271 if (IPAddress.TryParse(console_result, out ipAddressResult)) 271 {
272 { 272 convertSuccess = true;
273 convertSuccess = true; 273 return_result = ipAddressResult;
274 return_result = ipAddressResult; 274 }
275 } 275 errorMessage = "an IP Address (IPAddress)";
276 errorMessage = "an IP Address (IPAddress)"; 276 break;
277 break; 277 case ConfigurationOption.ConfigurationTypes.TYPE_LLUUID:
278 case ConfigurationOption.ConfigurationTypes.TYPE_LLUUID: 278 LLUUID uuidResult;
279 LLUUID uuidResult; 279 if (LLUUID.TryParse(console_result, out uuidResult))
280 if (LLUUID.TryParse(console_result, out uuidResult)) 280 {
281 { 281 convertSuccess = true;
282 convertSuccess = true; 282 return_result = uuidResult;
283 return_result = uuidResult; 283 }
284 } 284 errorMessage = "a UUID (LLUUID)";
285 errorMessage = "a UUID (LLUUID)"; 285 break;
286 break; 286 case ConfigurationOption.ConfigurationTypes.TYPE_LLVECTOR3:
287 case ConfigurationOption.ConfigurationTypes.TYPE_LLVECTOR3: 287 LLVector3 vectorResult;
288 LLVector3 vectorResult; 288 if (LLVector3.TryParse(console_result, out vectorResult))
289 if (LLVector3.TryParse(console_result, out vectorResult)) 289 {
290 { 290 convertSuccess = true;
291 convertSuccess = true; 291 return_result = vectorResult;
292 return_result = vectorResult; 292 }
293 } 293 errorMessage = "a vector (LLVector3)";
294 errorMessage = "a vector (LLVector3)"; 294 break;
295 break; 295 case ConfigurationOption.ConfigurationTypes.TYPE_UINT16:
296 case ConfigurationOption.ConfigurationTypes.TYPE_UINT16: 296 ushort ushortResult;
297 ushort ushortResult; 297 if (UInt16.TryParse(console_result, out ushortResult))
298 if (UInt16.TryParse(console_result, out ushortResult)) 298 {
299 { 299 convertSuccess = true;
300 convertSuccess = true; 300 return_result = ushortResult;
301 return_result = ushortResult; 301 }
302 } 302 errorMessage = "an unsigned 16 bit integer (ushort)";
303 errorMessage = "an unsigned 16 bit integer (ushort)"; 303 break;
304 break; 304 case ConfigurationOption.ConfigurationTypes.TYPE_UINT32:
305 case ConfigurationOption.ConfigurationTypes.TYPE_UINT32: 305 uint uintResult;
306 uint uintResult; 306 if (UInt32.TryParse(console_result, out uintResult))
307 if (UInt32.TryParse(console_result, out uintResult)) 307 {
308 { 308 convertSuccess = true;
309 convertSuccess = true; 309 return_result = uintResult;
310 return_result = uintResult; 310
311 311 }
312 } 312 errorMessage = "an unsigned 32 bit integer (uint)";
313 errorMessage = "an unsigned 32 bit integer (uint)"; 313 break;
314 break; 314 case ConfigurationOption.ConfigurationTypes.TYPE_UINT64:
315 case ConfigurationOption.ConfigurationTypes.TYPE_UINT64: 315 ulong ulongResult;
316 ulong ulongResult; 316 if (UInt64.TryParse(console_result, out ulongResult))
317 if (UInt64.TryParse(console_result, out ulongResult)) 317 {
318 { 318 convertSuccess = true;
319 convertSuccess = true; 319 return_result = ulongResult;
320 return_result = ulongResult; 320 }
321 } 321 errorMessage = "an unsigned 64 bit integer (ulong)";
322 errorMessage = "an unsigned 64 bit integer (ulong)"; 322 break;
323 break; 323 case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT:
324 case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT: 324 float floatResult;
325 float floatResult; 325 if (float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out floatResult))
326 if (float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out floatResult)) 326 {
327 { 327 convertSuccess = true;
328 convertSuccess = true; 328 return_result = floatResult;
329 return_result = floatResult; 329 }
330 } 330 errorMessage = "a single-precision floating point number (float)";
331 errorMessage = "a single-precision floating point number (float)"; 331 break;
332 break; 332 case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE:
333 case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE: 333 double doubleResult;
334 double doubleResult; 334 if (Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out doubleResult))
335 if (Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out doubleResult)) 335 {
336 { 336 convertSuccess = true;
337 convertSuccess = true; 337 return_result = doubleResult;
338 return_result = doubleResult; 338 }
339 } 339 errorMessage = "an double-precision floating point number (double)";
340 errorMessage = "an double-precision floating point number (double)"; 340 break;
341 break; 341 }
342 } 342
343 343 if (convertSuccess)
344 if (convertSuccess) 344 {
345 { 345 if (useFile)
346 if (useFile) 346 {
347 { 347 configurationPlugin.SetAttribute(configOption.configurationKey, console_result);
348 configurationPlugin.SetAttribute(configOption.configurationKey, console_result); 348 }
349 } 349
350 350
351 351 if (!this.resultFunction(configOption.configurationKey, return_result))
352 if (!this.resultFunction(configOption.configurationKey, return_result)) 352 {
353 { 353 Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again.");
354 Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again."); 354 convertSuccess = false;
355 convertSuccess = false; 355 ignoreNextFromConfig = true;
356 ignoreNextFromConfig = true; 356 }
357 } 357 }
358 } 358 else
359 else 359 {
360 { 360 if (configOption.configurationUseDefaultNoPrompt)
361 if (configOption.configurationUseDefaultNoPrompt) 361 {
362 { 362 MainLog.Instance.Error("CONFIG", string.Format("[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename));
363 MainLog.Instance.Error("CONFIG", string.Format("[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); 363 convertSuccess = true;
364 convertSuccess = true; 364 }
365 } 365 else
366 else 366 {
367 { 367 MainLog.Instance.Warn("CONFIG", string.Format("[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename));
368 MainLog.Instance.Warn("CONFIG", string.Format("[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); 368 ignoreNextFromConfig = true;
369 ignoreNextFromConfig = true; 369 }
370 } 370 }
371 } 371 }
372 } 372 }
373 } 373
374 374 if(useFile)
375 if(useFile) 375 {
376 { 376 configurationPlugin.Commit();
377 configurationPlugin.Commit(); 377 configurationPlugin.Close();
378 configurationPlugin.Close(); 378 }
379 } 379 }
380 } 380
381 381 private IGenericConfig LoadConfigDll(string dllName)
382 private IGenericConfig LoadConfigDll(string dllName) 382 {
383 { 383 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
384 Assembly pluginAssembly = Assembly.LoadFrom(dllName); 384 IGenericConfig plug = null;
385 IGenericConfig plug = null; 385
386 386 foreach (Type pluginType in pluginAssembly.GetTypes())
387 foreach (Type pluginType in pluginAssembly.GetTypes()) 387 {
388 { 388 if (pluginType.IsPublic)
389 if (pluginType.IsPublic) 389 {
390 { 390 if (!pluginType.IsAbstract)
391 if (!pluginType.IsAbstract) 391 {
392 { 392 Type typeInterface = pluginType.GetInterface("IGenericConfig", true);
393 Type typeInterface = pluginType.GetInterface("IGenericConfig", true); 393
394 394 if (typeInterface != null)
395 if (typeInterface != null) 395 {
396 { 396 plug = (IGenericConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
397 plug = (IGenericConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 397 }
398 } 398 }
399 } 399 }
400 } 400 }
401 } 401
402 402 pluginAssembly = null;
403 pluginAssembly = null; 403 return plug;
404 return plug; 404 }
405 } 405
406 406 public void forceSetConfigurationOption(string configuration_key, string configuration_value)
407 public void forceSetConfigurationOption(string configuration_key, string configuration_value) 407 {
408 { 408 this.configurationPlugin.LoadData();
409 this.configurationPlugin.LoadData(); 409 this.configurationPlugin.SetAttribute(configuration_key, configuration_value);
410 this.configurationPlugin.SetAttribute(configuration_key, configuration_value); 410 this.configurationPlugin.Commit();
411 this.configurationPlugin.Commit(); 411 this.configurationPlugin.Close();
412 this.configurationPlugin.Close(); 412 }
413 } 413 }
414 } 414}
415}