async Task ParseAsync(String url, CancellationToken cancel)
        {
            if (Options.IsStyling)
            {
                var stream = await LoadAsync(url, cancel);

                var parser = new CssParser(this, stream);
                await parser.ParseAsync();
            }
        }
Exemple #2
0
        public void TestAsyncCssParsingFromString()
        {
            var source = "h1 { color: red; } h2 { color: blue; } p { font-family: Arial; } div { margin: 10 }";
            var parser = new CssParser(source, Configuration.Default);
            var task   = parser.ParseAsync();

            Assert.IsTrue(task.IsCompleted);
            Assert.IsNotNull(parser.Result);

            Assert.AreEqual(4, parser.Result.Rules.Length);
        }
Exemple #3
0
        public void TestAsyncCssParsingFromStream()
        {
            var text   = "h1 { color: red; } h2 { color: blue; } p { font-family: Arial; } div { margin: 10 }";
            var source = new DelayedStream(Encoding.UTF8.GetBytes(text));
            var parser = new CssParser(source, Configuration.Default);
            var task   = parser.ParseAsync();

            Assert.IsFalse(task.IsCompleted);
            Assert.IsNotNull(parser.Result);
            task.Wait();
            Assert.IsTrue(task.IsCompleted);
            Assert.IsNotNull(parser.Result);

            Assert.AreEqual(4, parser.Result.Rules.Length);
        }