예제 #1
0
        /// <summary>
        /// Creates a new selector parser using the different factories.
        /// </summary>
        internal CssSelectorParser(IBrowsingContext context)
        {
            if (context == null)
            {
                context = BrowsingContext.NewFrom <ICssSelectorParser>(this);
            }

            _attribute     = context.GetFactory <IAttributeSelectorFactory>();
            _pseudoClass   = context.GetFactory <IPseudoClassSelectorFactory>();
            _pseudoElement = context.GetFactory <IPseudoElementSelectorFactory>();
        }
예제 #2
0
        public Event CreateEvent(String type)
        {
            var factory = _context.GetFactory <IEventFactory>();
            var ev      = factory.Create(type);

            if (ev == null)
            {
                throw new DomException(DomError.NotSupported);
            }

            return(ev);
        }
예제 #3
0
        internal static ICssProperty[] CreateLonghands(this IBrowsingContext context, ICssProperty shorthand)
        {
            var factory = context.GetFactory <IDeclarationFactory>();
            var info    = factory.Create(shorthand.Name);
            var values  = info.Expand(factory, shorthand.RawValue);

            return(factory.CreateProperties(info.Longhands, values, shorthand.IsImportant));
        }
        protected override async Task ProcessResponseAsync(IResponse response)
        {
            var context  = new BrowsingContext(_context, Sandboxes.None);
            var encoding = _context.GetDefaultEncoding();
            var options  = new CreateDocumentOptions(response, encoding, _parentDocument);
            var factory  = _context.GetFactory <IDocumentFactory>();

            ChildDocument = await factory.CreateAsync(context, options, CancellationToken.None).ConfigureAwait(false);
        }
        /// <summary>
        /// Opens a new document created from the response asynchronously in
        /// the given context.
        /// </summary>
        /// <param name="context">The browsing context to use.</param>
        /// <param name="response">The response to examine.</param>
        /// <param name="cancel">The cancellation token.</param>
        /// <returns>The task that creates the document.</returns>
        public static Task <IDocument> OpenAsync(this IBrowsingContext context, IResponse response, CancellationToken cancel = default)
        {
            response = response ?? throw new ArgumentNullException(nameof(response));
            context  = context ?? BrowsingContext.New();
            var encoding = context.GetDefaultEncoding();
            var factory  = context.GetFactory <IDocumentFactory>();
            var options  = new CreateDocumentOptions(response, encoding);

            return(factory.CreateAsync(context, options, cancel));
        }
예제 #6
0
        internal static ICssProperty CreateShorthand(this IBrowsingContext context, String name, ICssValue[] longhands, Boolean important)
        {
            var factory = context.GetFactory <IDeclarationFactory>();
            var info    = factory.Create(name);
            var value   = info.Collapse(factory, longhands);

            if (context.AllowsDeclaration(info))
            {
                return(new CssProperty(name, info.Converter, info.Flags, value, important));
            }

            return(null);
        }
        internal static DeclarationInfo GetDeclarationInfo(this IBrowsingContext context, String propertyName)
        {
            var factory = context.GetFactory <IDeclarationFactory>();

            return(factory.Create(propertyName));
        }