本文整理汇总了C#中AngleSharp.Parser.Css.CssParser.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# CssParser.Parse方法的具体用法?C# CssParser.Parse怎么用?C# CssParser.Parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AngleSharp.Parser.Css.CssParser
的用法示例。
在下文中一共展示了CssParser.Parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCssSelectorTest
static void CreateCssSelectorTest(IBrowsingContext context, String url, List<String> methods)
{
Console.Write("Loading " + url + " ... ");
var document = context.OpenAsync(url).Result;
var title = Sanatize(document.GetElementsByTagName("title")[0].TextContent);
var content = document.GetElementsByTagName("content")[0].InnerHtml.Trim().Replace("\"", "\"\"");
var styling = document.GetElementsByTagName("css")[0].TextContent;
var parser = new CssParser(styling);
var sheet = parser.Parse();
var selectors = new StringBuilder();
var i = 1;
if (methods.Contains(title))
{
var ltr = 'A';
while (methods.Contains(title + ltr.ToString()))
ltr = (Char)((int)ltr + 1);
title += ltr.ToString();
}
foreach (var rule in sheet.Rules)
{
if (rule is ICssStyleRule)
{
selectors.Append(@"
var selectorINDEX = doc.QuerySelectorAll(""SELECTOR"");
Assert.AreEqual(0, selectorINDEX.Length);"
.Replace("SELECTOR", ((ICssStyleRule)rule).SelectorText)
.Replace("INDEX", i.ToString()));
i++;
}
}
File.AppendAllText("test.cs", @"
/// <summary>
/// Test taken from URL
/// </summary>
public void TITLE()
{
var source = @""HTML"";
var doc = DocumentBuilder.Html(source);
SELECTORS
}
"
.Replace("URL", url)
.Replace("TITLE", title)
.Replace("HTML", content)
.Replace("SELECTORS", selectors.ToString())
);
Console.WriteLine("success.");
methods.Add(title);
}