aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/OpenSim.GenericConfig
diff options
context:
space:
mode:
Diffstat (limited to 'Common/OpenSim.GenericConfig')
-rw-r--r--Common/OpenSim.GenericConfig/Xml/XmlConfig.cs59
1 files changed, 23 insertions, 36 deletions
diff --git a/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs b/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs
index 40c252f..c526aec 100644
--- a/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs
+++ b/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs
@@ -49,45 +49,32 @@ namespace OpenSim.GenericConfig
49 public void LoadData() 49 public void LoadData()
50 { 50 {
51 doc = new XmlDocument(); 51 doc = new XmlDocument();
52 try
53 {
54 if (System.IO.File.Exists(fileName))
55 {
56 XmlTextReader reader = new XmlTextReader(fileName);
57 reader.WhitespaceHandling = WhitespaceHandling.None;
58 doc.Load(reader);
59 reader.Close();
60 }
61 else
62 {
63 createdFile = true;
64 rootNode = doc.CreateNode(XmlNodeType.Element, "Root", "");
65 doc.AppendChild(rootNode);
66 configNode = doc.CreateNode(XmlNodeType.Element, "Config", "");
67 rootNode.AppendChild(configNode);
68 }
69 52
70 } 53 if (System.IO.File.Exists(fileName))
71 catch (Exception e)
72 {
73 Console.WriteLine(e.Message);
74 return;
75 }
76 try
77 { 54 {
78 rootNode = doc.FirstChild; 55 XmlTextReader reader = new XmlTextReader(fileName);
79 if (rootNode.Name != "Root") 56 reader.WhitespaceHandling = WhitespaceHandling.None;
80 throw new Exception("Error: Invalid .xml File. Missing <Root>"); 57 doc.Load(reader);
81 58 reader.Close();
82 configNode = rootNode.FirstChild;
83 if (configNode.Name != "Config")
84 throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
85
86 } 59 }
87 catch (Exception e) 60 else
88 { 61 {
89 Console.WriteLine(e.Message); 62 createdFile = true;
63 rootNode = doc.CreateNode(XmlNodeType.Element, "Root", "");
64 doc.AppendChild(rootNode);
65 configNode = doc.CreateNode(XmlNodeType.Element, "Config", "");
66 rootNode.AppendChild(configNode);
90 } 67 }
68
69
70 rootNode = doc.FirstChild;
71 if (rootNode.Name != "Root")
72 throw new Exception("Error: Invalid .xml File. Missing <Root>");
73
74 configNode = rootNode.FirstChild;
75 if (configNode.Name != "Config")
76 throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
77
91 if (createdFile) 78 if (createdFile)
92 { 79 {
93 this.Commit(); 80 this.Commit();
@@ -108,7 +95,7 @@ namespace OpenSim.GenericConfig
108 { 95 {
109 if (configNode.Attributes[attributeName] != null) 96 if (configNode.Attributes[attributeName] != null)
110 { 97 {
111 ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; 98 ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
112 } 99 }
113 else 100 else
114 { 101 {
@@ -131,6 +118,6 @@ namespace OpenSim.GenericConfig
131 rootNode = null; 118 rootNode = null;
132 doc = null; 119 doc = null;
133 } 120 }
134 121
135 } 122 }
136} 123}