本文整理汇总了C#中ExecutionContext.NewBlock方法的典型用法代码示例。如果您正苦于以下问题:C# ExecutionContext.NewBlock方法的具体用法?C# ExecutionContext.NewBlock怎么用?C# ExecutionContext.NewBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecutionContext
的用法示例。
在下文中一共展示了ExecutionContext.NewBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteStatement
protected override void ExecuteStatement(ExecutionContext context)
{
var resultType = ConditionExpression.ReturnType(context.Request, null);
if (!(resultType is BooleanType))
throw new StatementException("The condition expression does not evaluate to a boolean.");
// The condition statement triggers the creation of a new context
var block = context.NewBlock(this);
var conditionResult = ConditionExpression.EvaluateToConstant(context.Request, null);
if (conditionResult) {
foreach (var statement in TrueStatements) {
statement.Execute(block);
if (block.HasTermination)
break;
}
} else if (FalseStatements != null) {
foreach (var statement in FalseStatements) {
statement.Execute(block);
if (block.HasTermination)
break;
}
}
}
示例2: ExecuteBlock
protected override void ExecuteBlock(ExecutionContext context)
{
BeforeLoop(context);
while (Loop(context)) {
var loopBlock = context.NewBlock(this);
if (CanExecute(loopBlock))
base.ExecuteBlock(loopBlock);
AfterLoop(context);
}
}