protected internal override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
{
string name = reader.Name;
base.DeserializeElement(reader, serializeCollectionKey);
if ((this.File != null) && (this.File.Length > 0))
{
string file;
string source = base.ElementInformation.Source;
if (string.IsNullOrEmpty(source))
{
file = this.File;
}
else
{
file = Path.Combine(Path.GetDirectoryName(source), this.File);
}
if (System.IO.File.Exists(file))
{
int lineOffset = 0;
string rawXml = null;
using (Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (XmlUtil util = new XmlUtil(stream, file, true))
{
if (util.Reader.Name != name)
{
throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_name_value_file_section_file_invalid_root", new object[] { name }), util);
}
lineOffset = util.Reader.LineNumber;
rawXml = util.CopySection();
while (!util.Reader.EOF)
{
if (util.Reader.NodeType != XmlNodeType.Comment)
{
throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_source_file_format"), util);
}
util.Reader.Read();
}
}
}
ConfigXmlReader reader2 = new ConfigXmlReader(rawXml, file, lineOffset);
reader2.Read();
if (reader2.MoveToNextAttribute())
{
throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_base_unrecognized_attribute", new object[] { reader2.Name }), reader2);
}
reader2.MoveToElement();
base.DeserializeElement(reader2, serializeCollectionKey);
}
}
}