aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Configuration/XML
diff options
context:
space:
mode:
authorSean Dague2007-07-30 20:11:40 +0000
committerSean Dague2007-07-30 20:11:40 +0000
commit74bb5282a09ec095a7ff810c62f79cc64e187686 (patch)
treee0a9b703bfcbbab59b04351dd71508fa913e741a /OpenSim/Framework/Configuration/XML
parentadded OnDisconnectUser event to required classes (diff)
downloadopensim-SC_OLD-74bb5282a09ec095a7ff810c62f79cc64e187686.zip
opensim-SC_OLD-74bb5282a09ec095a7ff810c62f79cc64e187686.tar.gz
opensim-SC_OLD-74bb5282a09ec095a7ff810c62f79cc64e187686.tar.bz2
opensim-SC_OLD-74bb5282a09ec095a7ff810c62f79cc64e187686.tar.xz
mass update of files to have native line endings
Diffstat (limited to 'OpenSim/Framework/Configuration/XML')
-rw-r--r--OpenSim/Framework/Configuration/XML/XmlConfiguration.cs266
1 files changed, 133 insertions, 133 deletions
diff --git a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs
index 5b66035..72faed6 100644
--- a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs
+++ b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs
@@ -1,133 +1,133 @@
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*/
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Xml; 30using System.Xml;
31 31
32using OpenSim.Framework.Interfaces; 32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Configuration.Interfaces; 33using OpenSim.Framework.Configuration.Interfaces;
34 34
35namespace OpenSim.Framework.Configuration 35namespace OpenSim.Framework.Configuration
36{ 36{
37 public class XmlConfiguration : IGenericConfig 37 public class XmlConfiguration : IGenericConfig
38 { 38 {
39 private XmlDocument doc; 39 private XmlDocument doc;
40 private XmlNode rootNode; 40 private XmlNode rootNode;
41 private XmlNode configNode; 41 private XmlNode configNode;
42 private string fileName; 42 private string fileName;
43 private bool createdFile = false; 43 private bool createdFile = false;
44 44
45 public void SetFileName(string file) 45 public void SetFileName(string file)
46 { 46 {
47 fileName = file; 47 fileName = file;
48 } 48 }
49 49
50 private void LoadDataToClass() 50 private void LoadDataToClass()
51 { 51 {
52 rootNode = doc.FirstChild; 52 rootNode = doc.FirstChild;
53 if (rootNode.Name != "Root") 53 if (rootNode.Name != "Root")
54 throw new Exception("Error: Invalid .xml File. Missing <Root>"); 54 throw new Exception("Error: Invalid .xml File. Missing <Root>");
55 55
56 configNode = rootNode.FirstChild; 56 configNode = rootNode.FirstChild;
57 if (configNode.Name != "Config") 57 if (configNode.Name != "Config")
58 throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); 58 throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
59 } 59 }
60 public void LoadData() 60 public void LoadData()
61 { 61 {
62 doc = new XmlDocument(); 62 doc = new XmlDocument();
63 if (File.Exists(fileName)) 63 if (File.Exists(fileName))
64 { 64 {
65 XmlTextReader reader = new XmlTextReader(fileName); 65 XmlTextReader reader = new XmlTextReader(fileName);
66 reader.WhitespaceHandling = WhitespaceHandling.None; 66 reader.WhitespaceHandling = WhitespaceHandling.None;
67 doc.Load(reader); 67 doc.Load(reader);
68 reader.Close(); 68 reader.Close();
69 } 69 }
70 else 70 else
71 { 71 {
72 createdFile = true; 72 createdFile = true;
73 rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); 73 rootNode = doc.CreateNode(XmlNodeType.Element, "Root", "");
74 doc.AppendChild(rootNode); 74 doc.AppendChild(rootNode);
75 configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); 75 configNode = doc.CreateNode(XmlNodeType.Element, "Config", "");
76 rootNode.AppendChild(configNode); 76 rootNode.AppendChild(configNode);
77 } 77 }
78 78
79 LoadDataToClass(); 79 LoadDataToClass();
80 80
81 if (createdFile) 81 if (createdFile)
82 { 82 {
83 this.Commit(); 83 this.Commit();
84 } 84 }
85 } 85 }
86 86
87 public void LoadDataFromString(string data) 87 public void LoadDataFromString(string data)
88 { 88 {
89 doc = new XmlDocument(); 89 doc = new XmlDocument();
90 doc.LoadXml(data); 90 doc.LoadXml(data);
91 91
92 LoadDataToClass(); 92 LoadDataToClass();
93 } 93 }
94 public string GetAttribute(string attributeName) 94 public string GetAttribute(string attributeName)
95 { 95 {
96 string result = null; 96 string result = null;
97 if (configNode.Attributes[attributeName] != null) 97 if (configNode.Attributes[attributeName] != null)
98 { 98 {
99 result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value; 99 result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value;
100 } 100 }
101 return result; 101 return result;
102 } 102 }
103 103
104 public bool SetAttribute(string attributeName, string attributeValue) 104 public bool SetAttribute(string attributeName, string attributeValue)
105 { 105 {
106 if (configNode.Attributes[attributeName] != null) 106 if (configNode.Attributes[attributeName] != null)
107 { 107 {
108 ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; 108 ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
109 } 109 }
110 else 110 else
111 { 111 {
112 XmlAttribute attri; 112 XmlAttribute attri;
113 attri = doc.CreateAttribute(attributeName); 113 attri = doc.CreateAttribute(attributeName);
114 attri.Value = attributeValue; 114 attri.Value = attributeValue;
115 configNode.Attributes.Append(attri); 115 configNode.Attributes.Append(attri);
116 } 116 }
117 return true; 117 return true;
118 } 118 }
119 119
120 public void Commit() 120 public void Commit()
121 { 121 {
122 doc.Save(fileName); 122 doc.Save(fileName);
123 } 123 }
124 124
125 public void Close() 125 public void Close()
126 { 126 {
127 configNode = null; 127 configNode = null;
128 rootNode = null; 128 rootNode = null;
129 doc = null; 129 doc = null;
130 } 130 }
131 131
132 } 132 }
133} 133}