+2006-10-13 Atsushi Enomoto <atsushi@ximian.com>
+
+ * ConfigurationSettings.cs : another MoveToNextElement() elimination.
+ When there is another section group after "system.drawing"
+ section in the existing machine.config, it borked as if there were
+ no "system.diagnostics" section.
+
+ It is still buggy; prepended sectionGroup still causes the above.
+
2006-10-13 Atsushi Enomoto <atsushi@ximian.com>
* ConfigurationSettings.cs : when there is no content in
}
#endif
reader = new XmlTextReader (fs);
- InitRead (reader);
- ReadConfigFile (reader);
+ if (InitRead (reader))
+ ReadConfigFile (reader);
} catch (ConfigurationException) {
throw;
} catch (Exception e) {
return null;
}
#if (XML_DEP)
- private void InitRead (XmlTextReader reader)
+ private bool InitRead (XmlTextReader reader)
{
reader.MoveToContent ();
if (reader.NodeType != XmlNodeType.Element || reader.Name != "configuration")
if (reader.HasAttributes)
ThrowException ("Unrecognized attribute in root element", reader);
-
- MoveToNextElement (reader);
+ if (reader.IsEmptyElement) {
+ reader.Skip ();
+ return false;
+ }
+ reader.Read ();
+ reader.MoveToContent ();
+ return reader.NodeType != XmlNodeType.EndElement;
}
// FIXME: this approach is not always safe and likely to cause bugs.
private void ReadConfigFile (XmlTextReader reader)
{
int depth = reader.Depth;
- while (!reader.EOF && reader.Depth == depth) {
+ for (reader.MoveToContent ();
+ !reader.EOF && reader.NodeType != XmlNodeType.EndElement;
+ reader.MoveToContent ()) {
string name = reader.Name;
if (name == "configSections") {
if (reader.HasAttributes)
ThrowException ("Unrecognized attribute in <configSections>.", reader);
-
- MoveToNextElement (reader);
- if (reader.Depth > depth)
- ReadSections (reader, null);
+ if (reader.IsEmptyElement)
+ reader.Skip ();
+ else {
+ reader.Read ();
+ reader.MoveToContent ();
+ if (reader.NodeType != XmlNodeType.EndElement)
+ ReadSections (reader, null);
+ else
+ reader.Read ();
+ }
} else if (name != null && name != "") {
StorePending (name, reader);
MoveToNextElement (reader);