internal static XmlReader CreateSqlXmlReader(Stream stream, bool closeInput = false, bool throwTargetInvocationExceptions = false)
{
// Call the internal delegate
XmlReaderSettings settingsToUse = closeInput ? s_defaultXmlReaderSettingsCloseInput : s_defaultXmlReaderSettings;
try
{
return s_sqlReaderDelegate(stream, settingsToUse, null);
}
// For particular callers, we need to wrap all exceptions inside a TargetInvocationException to simulate calling CreateSqlReader via MethodInfo.Invoke
catch (Exception ex)
{
if ((!throwTargetInvocationExceptions) || (!ADP.IsCatchableExceptionType(ex)))
{
throw;
}
else
{
throw new TargetInvocationException(ex);
}
}
}