override protected object GetRuntimeObject(object result) {
object runtimeObject;
ConfigurationSection section = result as ConfigurationSection;
if (section == null) {
runtimeObject = result;
}
else {
// Call into config section while impersonating process or UNC identity
// so that the section could read files from disk if needed
try {
using (Impersonate()) {
// If this configRecord is trusted, ignore user code on stack
if (_flags[IsTrusted]) {
runtimeObject = GetRuntimeObjectWithFullTrust(section);
}
else {
// Run configuration section handlers as if user code was on the stack
runtimeObject = GetRuntimeObjectWithRestrictedPermissions(section);
}
}
}
catch (Exception e) {
throw new ConfigurationErrorsException(SR.GetString(SR.Config_exception_in_config_section_handler, section.SectionInformation.SectionName), e);
}
catch {
throw new ConfigurationErrorsException(SR.GetString(SR.Config_exception_in_config_section_handler, section.SectionInformation.SectionName));
}
}
return runtimeObject;
}