protected ConfigXmlReader GetSectionXmlReader(string[] keys, SectionInput input) {
ConfigXmlReader reader = null;
string filename = input.SectionXmlInfo.Filename;
int lineNumber = input.SectionXmlInfo.LineNumber;
try {
string name = keys[keys.Length-1];
string rawXml = input.SectionXmlInfo.RawXml;
if (rawXml != null) {
// Use the stored raw xml to provide the content of the section.
reader = new ConfigXmlReader(rawXml, input.SectionXmlInfo.Filename, input.SectionXmlInfo.LineNumber);
}
else if (!String.IsNullOrEmpty(input.SectionXmlInfo.ConfigSource)) {
// Load the config source to provide the content of the section.
filename = input.SectionXmlInfo.ConfigSourceStreamName;
lineNumber = 0;
reader = LoadConfigSource(name, input.SectionXmlInfo);
}
else {
// Find the content of the section in the config file.
lineNumber = 0;
reader = FindSection(keys, input.SectionXmlInfo, out lineNumber);
}
if (reader != null) {
if (!input.IsProtectionProviderDetermined) {
input.ProtectionProvider = GetProtectionProviderFromName(input.SectionXmlInfo.ProtectionProviderName, false);
}
if (input.ProtectionProvider != null) {
reader = DecryptConfigSection(reader, input.ProtectionProvider);
}
}
}
//
// Guarantee that exceptions contain the name of the stream and an approximate line number.
//
catch (Exception e) {
throw ExceptionUtil.WrapAsConfigException(SR.GetString(SR.Config_error_loading_XML_file), e, filename, lineNumber);
}
catch {
throw ExceptionUtil.WrapAsConfigException(SR.GetString(SR.Config_error_loading_XML_file), null, filename, lineNumber);
}
return reader;
}