diff options
author | mingchen | 2007-07-18 23:15:08 +0000 |
---|---|---|
committer | mingchen | 2007-07-18 23:15:08 +0000 |
commit | 222becc8795d8abd8263c8abf8212de91faa4748 (patch) | |
tree | ac0eb1b420c2f60975b759296c94813f41925798 /OpenSim/Framework/GenericConfig | |
parent | * Reverting 1371 (diff) | |
download | opensim-SC_OLD-222becc8795d8abd8263c8abf8212de91faa4748.zip opensim-SC_OLD-222becc8795d8abd8263c8abf8212de91faa4748.tar.gz opensim-SC_OLD-222becc8795d8abd8263c8abf8212de91faa4748.tar.bz2 opensim-SC_OLD-222becc8795d8abd8263c8abf8212de91faa4748.tar.xz |
*New Configuration System, much easier and less buggy compared to the original system in place
*View RegionInfo.cs for an example on how it works!
*This hopefully copies all the files over, but who knows :)
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/General/Configuration/XmlConfiguration.cs (renamed from OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs) | 245 | ||||
-rw-r--r-- | OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs | 33 |
2 files changed, 123 insertions, 155 deletions
diff --git a/OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs b/OpenSim/Framework/General/Configuration/XmlConfiguration.cs index 2ed8d28..e1f3816 100644 --- a/OpenSim/Framework/GenericConfig/Xml/XmlConfig.cs +++ b/OpenSim/Framework/General/Configuration/XmlConfiguration.cs | |||
@@ -1,122 +1,123 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.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 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Xml; | 30 | using System.Xml; |
31 | using OpenSim.Framework.Interfaces; | 31 | |
32 | 32 | using OpenSim.Framework.Interfaces; | |
33 | namespace OpenSim.GenericConfig | 33 | |
34 | { | 34 | namespace OpenSim.Framework.Configuration |
35 | public class XmlConfig : IGenericConfig | 35 | { |
36 | { | 36 | public class XmlConfiguration : IGenericConfig |
37 | private XmlDocument doc; | 37 | { |
38 | private XmlNode rootNode; | 38 | private XmlDocument doc; |
39 | private XmlNode configNode; | 39 | private XmlNode rootNode; |
40 | private string fileName; | 40 | private XmlNode configNode; |
41 | private bool createdFile = false; | 41 | private string fileName; |
42 | 42 | private bool createdFile = false; | |
43 | public XmlConfig(string filename) | 43 | |
44 | { | 44 | public XmlConfiguration(string filename) |
45 | fileName = filename; | 45 | { |
46 | } | 46 | fileName = filename; |
47 | 47 | } | |
48 | public void LoadData() | 48 | |
49 | { | 49 | public void LoadData() |
50 | doc = new XmlDocument(); | 50 | { |
51 | 51 | doc = new XmlDocument(); | |
52 | if (File.Exists(fileName)) | 52 | |
53 | { | 53 | if (File.Exists(fileName)) |
54 | XmlTextReader reader = new XmlTextReader(fileName); | 54 | { |
55 | reader.WhitespaceHandling = WhitespaceHandling.None; | 55 | XmlTextReader reader = new XmlTextReader(fileName); |
56 | doc.Load(reader); | 56 | reader.WhitespaceHandling = WhitespaceHandling.None; |
57 | reader.Close(); | 57 | doc.Load(reader); |
58 | } | 58 | reader.Close(); |
59 | else | 59 | } |
60 | { | 60 | else |
61 | createdFile = true; | 61 | { |
62 | rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); | 62 | createdFile = true; |
63 | doc.AppendChild(rootNode); | 63 | rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); |
64 | configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); | 64 | doc.AppendChild(rootNode); |
65 | rootNode.AppendChild(configNode); | 65 | configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); |
66 | } | 66 | rootNode.AppendChild(configNode); |
67 | 67 | } | |
68 | 68 | ||
69 | rootNode = doc.FirstChild; | 69 | |
70 | if (rootNode.Name != "Root") | 70 | rootNode = doc.FirstChild; |
71 | throw new Exception("Error: Invalid .xml File. Missing <Root>"); | 71 | if (rootNode.Name != "Root") |
72 | 72 | throw new Exception("Error: Invalid .xml File. Missing <Root>"); | |
73 | configNode = rootNode.FirstChild; | 73 | |
74 | if (configNode.Name != "Config") | 74 | configNode = rootNode.FirstChild; |
75 | throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); | 75 | if (configNode.Name != "Config") |
76 | 76 | throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); | |
77 | if (createdFile) | 77 | |
78 | { | 78 | if (createdFile) |
79 | this.Commit(); | 79 | { |
80 | } | 80 | this.Commit(); |
81 | } | 81 | } |
82 | 82 | } | |
83 | public string GetAttribute(string attributeName) | 83 | |
84 | { | 84 | public string GetAttribute(string attributeName) |
85 | string result = ""; | 85 | { |
86 | if (configNode.Attributes[attributeName] != null) | 86 | string result = null; |
87 | { | 87 | if (configNode.Attributes[attributeName] != null) |
88 | result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value; | 88 | { |
89 | } | 89 | result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value; |
90 | return result; | 90 | } |
91 | } | 91 | return result; |
92 | 92 | } | |
93 | public bool SetAttribute(string attributeName, string attributeValue) | 93 | |
94 | { | 94 | public bool SetAttribute(string attributeName, string attributeValue) |
95 | if (configNode.Attributes[attributeName] != null) | 95 | { |
96 | { | 96 | if (configNode.Attributes[attributeName] != null) |
97 | ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; | 97 | { |
98 | } | 98 | ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; |
99 | else | 99 | } |
100 | { | 100 | else |
101 | XmlAttribute attri; | 101 | { |
102 | attri = doc.CreateAttribute(attributeName); | 102 | XmlAttribute attri; |
103 | attri.Value = attributeValue; | 103 | attri = doc.CreateAttribute(attributeName); |
104 | configNode.Attributes.Append(attri); | 104 | attri.Value = attributeValue; |
105 | } | 105 | configNode.Attributes.Append(attri); |
106 | return true; | 106 | } |
107 | } | 107 | return true; |
108 | 108 | } | |
109 | public void Commit() | 109 | |
110 | { | 110 | public void Commit() |
111 | doc.Save(fileName); | 111 | { |
112 | } | 112 | doc.Save(fileName); |
113 | 113 | } | |
114 | public void Close() | 114 | |
115 | { | 115 | public void Close() |
116 | configNode = null; | 116 | { |
117 | rootNode = null; | 117 | configNode = null; |
118 | doc = null; | 118 | rootNode = null; |
119 | } | 119 | doc = null; |
120 | 120 | } | |
121 | } | 121 | |
122 | } | 122 | } |
123 | } | ||
diff --git a/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs b/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs deleted file mode 100644 index 28779ee..0000000 --- a/OpenSim/Framework/GenericConfig/Xml/Properties/AssemblyInfo.cs +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.InteropServices; | ||
3 | // General Information about an assembly is controlled through the following | ||
4 | // set of attributes. Change these attribute values to modify the information | ||
5 | // associated with an assembly. | ||
6 | [assembly: AssemblyTitle("OpenSim.GenericConfig")] | ||
7 | [assembly: AssemblyDescription("")] | ||
8 | [assembly: AssemblyConfiguration("")] | ||
9 | [assembly: AssemblyCompany("")] | ||
10 | [assembly: AssemblyProduct("OpenSim.GenericConfig")] | ||
11 | [assembly: AssemblyCopyright("Copyright © 2007")] | ||
12 | [assembly: AssemblyTrademark("")] | ||
13 | [assembly: AssemblyCulture("")] | ||
14 | |||
15 | // Setting ComVisible to false makes the types in this assembly not visible | ||
16 | // to COM components. If you need to access a type in this assembly from | ||
17 | // COM, set the ComVisible attribute to true on that type. | ||
18 | [assembly: ComVisible(false)] | ||
19 | |||
20 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
21 | [assembly: Guid("285a3047-f165-46c8-8767-b51428738a09")] | ||
22 | |||
23 | // Version information for an assembly consists of the following four values: | ||
24 | // | ||
25 | // Major Version | ||
26 | // Minor Version | ||
27 | // Build Number | ||
28 | // Revision | ||
29 | // | ||
30 | // You can specify all the values or you can default the Revision and Build Numbers | ||
31 | // by using the '*' as shown below: | ||
32 | [assembly: AssemblyVersion("1.0.0.0")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||