diff options
Diffstat (limited to 'OpenSim/Framework/General/Configuration/ConfigurationMember.cs')
-rw-r--r-- | OpenSim/Framework/General/Configuration/ConfigurationMember.cs | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs b/OpenSim/Framework/General/Configuration/ConfigurationMember.cs index e93a576..4546683 100644 --- a/OpenSim/Framework/General/Configuration/ConfigurationMember.cs +++ b/OpenSim/Framework/General/Configuration/ConfigurationMember.cs | |||
@@ -1,4 +1,5 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Reflection; | ||
2 | using System.Collections; | 3 | using System.Collections; |
3 | using System.Collections.Generic; | 4 | using System.Collections.Generic; |
4 | using System.Text; | 5 | using System.Text; |
@@ -7,6 +8,7 @@ using System.Net; | |||
7 | using libsecondlife; | 8 | using libsecondlife; |
8 | 9 | ||
9 | using OpenSim.Framework.Console; | 10 | using OpenSim.Framework.Console; |
11 | using OpenSim.Framework.Configuration.Interfaces; | ||
10 | 12 | ||
11 | namespace OpenSim.Framework.Configuration | 13 | namespace OpenSim.Framework.Configuration |
12 | { | 14 | { |
@@ -22,12 +24,14 @@ namespace OpenSim.Framework.Configuration | |||
22 | private ConfigurationOptionsLoad loadFunction; | 24 | private ConfigurationOptionsLoad loadFunction; |
23 | private ConfigurationOptionResult resultFunction; | 25 | private ConfigurationOptionResult resultFunction; |
24 | 26 | ||
27 | private IGenericConfig configurationPlugin = null; | ||
25 | public ConfigurationMember(string configuration_filename, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) | 28 | public ConfigurationMember(string configuration_filename, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) |
26 | { | 29 | { |
27 | this.configurationFilename = configuration_filename; | 30 | this.configurationFilename = configuration_filename; |
28 | this.configurationDescription = configuration_description; | 31 | this.configurationDescription = configuration_description; |
29 | this.loadFunction = load_function; | 32 | this.loadFunction = load_function; |
30 | this.resultFunction = result_function; | 33 | this.resultFunction = result_function; |
34 | this.configurationPlugin = this.LoadConfigDll("OpenSim.Framework.Configuration.XML.dll"); | ||
31 | } | 35 | } |
32 | 36 | ||
33 | public void setConfigurationFilename(string filename) | 37 | public void setConfigurationFilename(string filename) |
@@ -91,18 +95,19 @@ namespace OpenSim.Framework.Configuration | |||
91 | } | 95 | } |
92 | 96 | ||
93 | bool useFile = true; | 97 | bool useFile = true; |
94 | XmlConfiguration xmlConfig = null; | 98 | if (configurationPlugin == null) |
95 | if (configurationFilename.Trim() != "") | ||
96 | { | 99 | { |
97 | xmlConfig = new XmlConfiguration(configurationFilename); | 100 | MainLog.Instance.Error("Configuration Plugin NOT LOADED!"); |
98 | 101 | return; | |
99 | } | 102 | } |
100 | 103 | ||
101 | if(xmlConfig != null) | 104 | if (configurationFilename.Trim() != "") |
102 | { | 105 | { |
103 | xmlConfig.LoadData(); | 106 | configurationPlugin.SetFileName(configurationFilename); |
107 | configurationPlugin.LoadData(); | ||
104 | useFile = true; | 108 | useFile = true; |
105 | } | 109 | } |
110 | |||
106 | else | 111 | else |
107 | { | 112 | { |
108 | MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file."); | 113 | MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file."); |
@@ -124,7 +129,7 @@ namespace OpenSim.Framework.Configuration | |||
124 | { | 129 | { |
125 | if (!ignoreNextFromConfig) | 130 | if (!ignoreNextFromConfig) |
126 | { | 131 | { |
127 | attribute = xmlConfig.GetAttribute(configOption.configurationKey); | 132 | attribute = configurationPlugin.GetAttribute(configOption.configurationKey); |
128 | } | 133 | } |
129 | else | 134 | else |
130 | { | 135 | { |
@@ -304,7 +309,7 @@ namespace OpenSim.Framework.Configuration | |||
304 | { | 309 | { |
305 | if (useFile) | 310 | if (useFile) |
306 | { | 311 | { |
307 | xmlConfig.SetAttribute(configOption.configurationKey, console_result); | 312 | configurationPlugin.SetAttribute(configOption.configurationKey, console_result); |
308 | } | 313 | } |
309 | 314 | ||
310 | 315 | ||
@@ -333,9 +338,34 @@ namespace OpenSim.Framework.Configuration | |||
333 | 338 | ||
334 | if(useFile) | 339 | if(useFile) |
335 | { | 340 | { |
336 | xmlConfig.Commit(); | 341 | configurationPlugin.Commit(); |
337 | xmlConfig.Close(); | 342 | configurationPlugin.Close(); |
338 | } | 343 | } |
339 | } | 344 | } |
345 | |||
346 | private IGenericConfig LoadConfigDll(string dllName) | ||
347 | { | ||
348 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
349 | IGenericConfig plug = null; | ||
350 | |||
351 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
352 | { | ||
353 | if (pluginType.IsPublic) | ||
354 | { | ||
355 | if (!pluginType.IsAbstract) | ||
356 | { | ||
357 | Type typeInterface = pluginType.GetInterface("IGenericConfig", true); | ||
358 | |||
359 | if (typeInterface != null) | ||
360 | { | ||
361 | plug = (IGenericConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
362 | } | ||
363 | } | ||
364 | } | ||
365 | } | ||
366 | |||
367 | pluginAssembly = null; | ||
368 | return plug; | ||
369 | } | ||
340 | } | 370 | } |
341 | } | 371 | } |