コード例 #1
0
ファイル: SvgDocument.cs プロジェクト: Wojdav/AngleSharp
 internal async static Task<IDocument> LoadAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancelToken)
 {
     var parserOptions = new XmlParserOptions { };
     var document = new SvgDocument(context, options.Source);
     var factory = context.Configuration.GetFactory<IElementFactory<SvgElement>>();
     var parser = new XmlDomBuilder(document, factory.Create);
     document.Setup(options);
     context.NavigateTo(document);
     context.Fire(new HtmlParseEvent(document, completed: false));
     await parser.ParseAsync(parserOptions, cancelToken).ConfigureAwait(false);
     context.Fire(new HtmlParseEvent(document, completed: true));
     return document;
 }
コード例 #2
0
ファイル: SvgDocument.cs プロジェクト: flagbug/AngleSharp
        internal async static Task <IDocument> LoadAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancelToken)
        {
            var parserOptions = new XmlParserOptions {
            };
            var document      = new SvgDocument(context, options.Source);
            var parser        = new XmlDomBuilder(document);

            document.Setup(options);
            context.NavigateTo(document);
            context.Fire(new HtmlParseEvent(document, completed: false));
            await parser.ParseAsync(parserOptions, cancelToken).ConfigureAwait(false);

            context.Fire(new HtmlParseEvent(document, completed: true));
            return(document);
        }
コード例 #3
0
ファイル: SvgDocument.cs プロジェクト: fjwuyongzhi/AngleSharp
        /// <summary>
        /// Loads the document in the provided context from the given response.
        /// </summary>
        /// <param name="context">The browsing context.</param>
        /// <param name="options">The creation options to consider.</param>
        /// <param name="cancelToken">Token for cancellation.</param>
        /// <returns>The task that builds the document.</returns>
        internal async static Task<IDocument> LoadAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancelToken)
        {
            var document = new SvgDocument(context, options.Source);
            var evt = new HtmlParseStartEvent(document);
            var events = context.Configuration.Events;
            var parser = new XmlDomBuilder(document);
            document.Setup(options);
            context.NavigateTo(document);

            if (events != null)
                events.Publish(evt);

            await parser.ParseAsync(default(XmlParserOptions), cancelToken).ConfigureAwait(false);
            evt.FireEnd();
            return document;
        }
コード例 #4
0
ファイル: SvgDocument.cs プロジェクト: neelendu/AngleSharp
        /// <summary>
        /// Loads the document in the provided context from the given response.
        /// </summary>
        /// <param name="context">The browsing context.</param>
        /// <param name="options">The creation options to consider.</param>
        /// <param name="cancelToken">Token for cancellation.</param>
        /// <returns>The task that builds the document.</returns>
        internal async static Task <IDocument> LoadAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancelToken)
        {
            var document = new SvgDocument(context, options.Source);
            var evt      = new HtmlParseStartEvent(document);
            var events   = context.Configuration.Events;
            var parser   = new XmlDomBuilder(document);

            document.Setup(options);
            context.NavigateTo(document);

            if (events != null)
            {
                events.Publish(evt);
            }

            await parser.ParseAsync(default(XmlParserOptions), cancelToken).ConfigureAwait(false);

            evt.FireEnd();
            return(document);
        }