Load() public method

Loads the XML document from the specified XmlReader.
public Load ( XmlReader reader ) : void
reader System.Xml.XmlReader
return void
Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
		/// <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;
		}