Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在较新版本的AngleSharp中,CssNode的等价物是什么?_C#_Anglesharp - Fatal编程技术网

C# 在较新版本的AngleSharp中,CssNode的等价物是什么?

C# 在较新版本的AngleSharp中,CssNode的等价物是什么?,c#,anglesharp,C#,Anglesharp,我有一段类似于AngleSharp 0.9.3的代码: public IEnumerable<CssNode> FindNodesInStyle(StyleContext context) { if (context is InternalStyleContext) { var nodes = new HashSet<CssNode>(); var styleSheet = context.ProcessedStyleSh

我有一段类似于AngleSharp 0.9.3的代码:

public IEnumerable<CssNode> FindNodesInStyle(StyleContext context)
{
    if (context is InternalStyleContext)
    {
        var nodes = new HashSet<CssNode>();

        var styleSheet = context.ProcessedStyleSheet;
        var rules = this.GetRules(styleSheet);
        foreach (var rule in rules)
        {
            var node = styleSheet.ParseTree.GetAssociatedNode(rule);
            if (node != null && !nodes.Contains(node))
            {
                nodes.Add(node);
            }
        }

        return nodes;
    }
    else
    {
        return new CssNode[] { };
    }
}
public IEnumerable FindNodeInstyle(样式上下文)
{
if(上下文是InternalStyleContext)
{
var nodes=newhashset();
var styleSheet=context.ProcessedStyleSheet;
var rules=this.GetRules(样式表);
foreach(规则中的var规则)
{
var node=styleSheet.ParseTree.GetAssociatedNode(规则);
if(node!=null&&!nodes.Contains(node))
{
nodes.Add(node);
}
}
返回节点;
}
其他的
{
返回新的CssNode[]{};
}
}

我正在尝试将我的AngleSharp更新到最新版本-目前为0.12.1-并且CssNode已被删除。我已经导入,但它也不包含CssNode类。

不幸的是,CSS比这复杂得多(即AngleSharp v0.10之前的版本)。如果您寻找一种几乎可以用于任何CSS的类型,最接近的将是
IStyleFormattable
。否则,如果您只查找规则,则
ICssRule
将适合您

不确定你想对你的代码做什么-AngleSharp.Css已经提供了帮助,例如,让你获得所有规则(包括子体等-也遵循媒体规则和类似规则,如果它们适用的话)

如果你给出更多的细节,我会相应地更新答案

希望有帮助