本文整理汇总了C#中Element.GetRoot方法的典型用法代码示例。如果您正苦于以下问题:C# Element.GetRoot方法的具体用法?C# Element.GetRoot怎么用?C# Element.GetRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element.GetRoot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Mixin
/// <summary>
/// TODO: Added quick fix for multipule mixins, but need to add mixins with variables which will changes things a bit
/// </summary>
/// <param name="node"></param>
/// <param name="element"></param>
// private void OldMixin(PegNode node, Element element)
// {
// var root = element.GetRoot();
// foreach (var el in Selectors(node.child_, els => els))
// root = root.Descend(el.Selector, el);
// if (root.Rules != null) element.Rules.AddRange(root.Rules);
// }
private void Mixin(PegNode node, Element element)
{
var root = element.GetRoot();
var rules = new List<INode>();
var selectors = Selectors(node.child_, els => els);
if (selectors.Count() > 1)
{
foreach (var el in selectors)
root = root.Descend(el.Selector, el);
if (root.Rules != null) element.Rules.AddRange(root.Rules);
}
else
{
var el = selectors.First();
foreach (var mixinElement in root.Nearests(el.Name))
{
if (mixinElement.Rules != null) rules.AddRange(mixinElement.Rules);
}
element.Rules.AddRange(rules);
}
}
示例2: RuleSet
/// <summary>
/// ruleset: selectors [{] ws prsimary ws [}] ws / ws selectors ';' ws;
/// </summary>
/// <param name="node"></param>
/// <param name="element"></param>
private void RuleSet(PegNode node, Element element)
{
if (node.id_.ToEnLess() == EnLess.standard_ruleset)
{
node = node.child_;
var elements = Selectors(node, element, els => StandardSelectors(element, els));
foreach (var el in elements)
Primary(node.next_, el);
}
else if (node.id_.ToEnLess() == EnLess.mixin_ruleset)
{
node = node.child_;
var elements = Selectors(node, element, els => els);
foreach (var el in elements){
var root = element.GetRoot();
var rules = root.Descend(el.Selector, el).Rules;
element.Rules.AddRange(rules);
}
}
}