XmlDocument GetDocumentForSection(string sectionName) { ConfigXmlDocument doc = new ConfigXmlDocument(); if (pending == null) { return(doc); } string [] sectionPath = sectionName.Split('/'); string outerxml = pending [sectionPath [0]] as string; if (outerxml == null) { return(doc); } StringReader reader = new StringReader(outerxml); XmlTextReader rd = new XmlTextReader(reader); rd.MoveToContent(); doc.LoadSingleElement(fileName, rd); return(GetInnerDoc(doc, 0, sectionPath)); }
private object EvaluateRecursive(IConfigurationSectionHandler factory, object config, string [] keys, int iKey, XmlTextReader reader) { string name = keys[iKey]; TraceVerbose(" EvaluateRecursive " + iKey + " " + name); int depth = reader.Depth; while (reader.Read() && reader.NodeType != XmlNodeType.Element) { ; } while (reader.Depth == depth + 1) { TraceVerbose(" EvaluateRecursive " + iKey + " " + name + " Name:" + reader.Name); if (reader.Name == name) { if (iKey < keys.Length - 1) { config = EvaluateRecursive(factory, config, keys, iKey + 1, reader); } else { TraceVerbose(" EvaluateRecursive " + iKey + " calling Create()"); Debug.Assert(iKey == keys.Length - 1); // // Call configuration section handler // // - try-catch is necessary to insulate config system from exceptions in user config handlers. // - bubble ConfigurationExceptions & XmlException // - wrap all others in ConfigurationException // int line = reader.LineNumber; try { ConfigXmlDocument doc = new ConfigXmlDocument(); doc.LoadSingleElement(_filename, reader); config = factory.Create(config, null, doc.DocumentElement); } catch (ConfigurationException) { throw; } catch (XmlException) { throw; } catch (Exception ex) { throw new ConfigurationException( SR.GetString(SR.Exception_in_config_section_handler), ex, _filename, line); } } continue; } StrictSkipToNextElement(reader); } return(config); }
XmlDocument GetDocumentForSection (string sectionName) { ConfigXmlDocument doc = new ConfigXmlDocument (); if (pending == null) return doc; string [] sectionPath = sectionName.Split ('/'); string outerxml = pending [sectionPath [0]] as string; if (outerxml == null) return doc; StringReader reader = new StringReader (outerxml); XmlTextReader rd = new XmlTextReader (reader); rd.MoveToContent (); doc.LoadSingleElement (fileName, rd); return GetInnerDoc (doc, 0, sectionPath); }
private object EvaluateRecursive(IConfigurationSectionHandler factory, object config, string [] keys, int iKey, XmlTextReader reader) { string name = keys[iKey]; TraceVerbose(" EvaluateRecursive " + iKey + " " + name); int depth = reader.Depth; while (reader.Read() && reader.NodeType != XmlNodeType.Element); while (reader.Depth == depth + 1) { TraceVerbose(" EvaluateRecursive " + iKey + " " + name + " Name:" + reader.Name); if (reader.Name == name) { if (iKey < keys.Length - 1) { config = EvaluateRecursive(factory, config, keys, iKey + 1, reader); } else { TraceVerbose(" EvaluateRecursive " + iKey + " calling Create()"); Debug.Assert(iKey == keys.Length - 1); // // Call configuration section handler // // - try-catch is necessary to insulate config system from exceptions in user config handlers. // - bubble ConfigurationExceptions & XmlException // - wrap all others in ConfigurationException // int line = reader.LineNumber; try { ConfigXmlDocument doc = new ConfigXmlDocument(); doc.LoadSingleElement(_filename, reader); config = factory.Create(config, null, doc.DocumentElement); } catch (ConfigurationException) { throw; } catch (XmlException) { throw; } catch (Exception ex) { throw new ConfigurationException( SR.GetString(SR.Exception_in_config_section_handler), ex, _filename, line); } } continue; } StrictSkipToNextElement(reader); } return config; }