本文整理汇总了C#中Env.CreateChildEnvWithClosure方法的典型用法代码示例。如果您正苦于以下问题:C# Env.CreateChildEnvWithClosure方法的具体用法?C# Env.CreateChildEnvWithClosure怎么用?C# Env.CreateChildEnvWithClosure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Env
的用法示例。
在下文中一共展示了Env.CreateChildEnvWithClosure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
public Ruleset Evaluate(List<NamedArgument> args, Env env, List<Ruleset> closureFrames)
{
var childEnv = env.CreateChildEnvWithClosure(new Closure() {Context = closureFrames, Ruleset = this});
return Evaluate(args, childEnv);
}
示例2: Evaluate
public override Node Evaluate(Env env)
{
var closures = env.FindRulesets(Selector);
if (closures == null)
throw new ParsingException(Selector.ToCSS(env).Trim() + " is undefined", Location);
env.Rule = this;
var rules = new NodeList();
if (PreComments)
rules.AddRange(PreComments);
var rulesetList = closures.ToList();
// To address bug https://github.com/dotless/dotless/issues/136, where a mixin and ruleset selector may have the same name, we
// need to favour matching a MixinDefinition with the required Selector and only fall back to considering other Ruleset types
// if no match is found.
// However, in order to support having a regular ruleset with the same name as a parameterized
// mixin (see https://github.com/dotless/dotless/issues/387), we need to take argument counts into account, so we make the
// decision after evaluating for argument match.
var mixins = rulesetList.Where(c => c.Ruleset is MixinDefinition).ToList();
var defaults = new List<Closure>();
bool foundMatches = false, foundExactMatches = false, foundDefaultMatches = false;
foreach (var closure in mixins)
{
var ruleset = (MixinDefinition)closure.Ruleset;
var matchType = ruleset.MatchArguments(Arguments, env);
if (matchType == MixinMatch.ArgumentMismatch)
{
continue;
}
if (matchType == MixinMatch.Default) {
defaults.Add(closure);
foundDefaultMatches = true;
continue;
}
foundMatches = true;
if (matchType == MixinMatch.GuardFail)
{
continue;
}
foundExactMatches = true;
try
{
var closureEnvironment = env.CreateChildEnvWithClosure(closure);
rules.AddRange(ruleset.Evaluate(Arguments, closureEnvironment).Rules);
}
catch (ParsingException e)
{
throw new ParsingException(e.Message, e.Location, Location);
}
}
if (!foundExactMatches && foundDefaultMatches) {
foreach (var closure in defaults) {
try {
var closureEnvironment = env.CreateChildEnvWithClosure(closure);
var ruleset = (MixinDefinition) closure.Ruleset;
rules.AddRange(ruleset.Evaluate(Arguments, closureEnvironment).Rules);
} catch (ParsingException e) {
throw new ParsingException(e.Message, e.Location, Location);
}
}
foundMatches = true;
}
if (!foundMatches)
{
var regularRulesets = rulesetList.Except(mixins);
foreach (var closure in regularRulesets)
{
if (closure.Ruleset.Rules != null) {
var nodes = (NodeList)closure.Ruleset.Rules.Clone();
NodeHelper.ExpandNodes<MixinCall>(env, nodes);
rules.AddRange(nodes);
}
foundMatches = true;
}
}
if (PostComments)
rules.AddRange(PostComments);
env.Rule = null;
if (!foundMatches)
{
//.........这里部分代码省略.........