/// <summary> /// Parses a XAML document using an XmlReader. /// </summary> public static XamlDocument Parse(XmlReader reader, XamlParserSettings settings) { if (reader == null) { throw new ArgumentNullException("reader"); } if (settings == null) { throw new ArgumentNullException("settings"); } XmlDocument doc = new PositionXmlDocument(); var errorSink = (IXamlErrorSink)settings.ServiceProvider.GetService(typeof(IXamlErrorSink)); try { doc.Load(reader); return(Parse(doc, settings)); } catch (XmlException x) { if (errorSink != null) { errorSink.ReportError(x.Message, x.LineNumber, x.LinePosition); } else { throw; } } return(null); }
/// <summary> /// Parses a XAML document using an XmlReader. /// </summary> public static XamlDocument Parse(XmlReader reader, XamlParserSettings settings) { if (reader == null) throw new ArgumentNullException("reader"); if (settings == null) throw new ArgumentNullException("settings"); XmlDocument doc = new PositionXmlDocument(); var errorSink = (IXamlErrorSink)settings.ServiceProvider.GetService(typeof(IXamlErrorSink)); try { doc.Load(reader); return Parse(doc, settings); } catch (XmlException x) { if (errorSink != null) { errorSink.ReportError(x.Message, x.LineNumber, x.LinePosition); } else { throw; } } return null; }