本文整理汇总了C#中IExecutionContext.CreateChildContext方法的典型用法代码示例。如果您正苦于以下问题:C# IExecutionContext.CreateChildContext方法的具体用法?C# IExecutionContext.CreateChildContext怎么用?C# IExecutionContext.CreateChildContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExecutionContext
的用法示例。
在下文中一共展示了IExecutionContext.CreateChildContext方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: For
public static IValue For(IExecutionContext ctx, IList<IArgument> arguments)
{
var args = CommandUtilities.ManageArguments(arguments)
.Exactly(4)
.CanConvert<IExecutable>()
.Results();
IExecutionContext outerCtx = ctx.CreateChildContext();
IExecutable initializer = args[0].GetValue<IExecutable>();
IExecutable check = args[1].GetValue<IExecutable>();
IExecutable increment = args[2].GetValue<IExecutable>();
IExecutable execute = args[3].GetValue<IExecutable>();
outerCtx.Execute(initializer);
IValue lastValue = GenericValue<object>.Default;
while(outerCtx.Execute(check).GetValue<bool>())
{
IExecutionContext innerCtx = outerCtx.CreateChildContext();
lastValue = innerCtx.Execute(execute, breakable: true);
if (execute.DidBreak())
break;
outerCtx.Execute(increment);
}
return lastValue;
}
示例2: Eval
public override object Eval(IExecutionContext context)
{
this.Context = context.CreateChildContext();
Parameters.Run(context);
if(this.Name != null)
context.InitVariable(this.Name, this);
return this;
}
示例3: Run
public override void Run(IExecutionContext context)
{
foreach(object val in (IEnumerable)enumerable.Eval(context))
{
using(IExecutionContext child_context = context.CreateChildContext())
{
variable.Run(context);
variable.AssignValue(context, val);
if(ExecuteSingleIteration(child_context, false) == TerminationReason.Break)
break;
}
}
}
示例4: Run
public override void Run(IExecutionContext context)
{
IExecutionContext child_context =
CreateChildContext ? context.CreateChildContext() : context;
try
{
Statements.Run(child_context);
}
finally
{
if(CreateChildContext)
child_context.Dispose();
}
}
示例5: Time
public static IValue Time(IExecutionContext ctx, IList<IArgument> arguments)
{
var args = CommandUtilities.ManageArguments(arguments)
.Exactly(1)
.CanConvert<IExecutable>()
.Results();
IExecutable execute = args[0].GetValue<IExecutable>();
IExecutionContext localCtx = ctx.CreateChildContext();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
execute.Execute(localCtx);
stopwatch.Stop();
return new GenericValue<double>(stopwatch.Elapsed.TotalSeconds);
}
示例6: CreateNew
public static IValue CreateNew(IExecutionContext ctx, IList<IArgument> arguments)
{
var args = CommandUtilities.ManageArguments(arguments)
.Exactly(0)
.Results();
IExecutionContext dict = ctx.CreateChildContext();
dict.DefineVariable("+object", new ConstantVariable(new GenericValue<Dictionary<IValue, IValue>>(new Dictionary<IValue, IValue>())));
dict.RegisterCommand("add", Add);
dict.RegisterCommand("get", Get);
dict.RegisterCommand("clear", Clear);
dict.RegisterCommand("containsKey", ContainsKey);
dict.RegisterCommand("containsValue", ContainsValue);
return new GenericValue<IExecutionContext>(dict);
}
示例7: CreateEmptyModule
public static IExecutionContext CreateEmptyModule(IExecutionContext ctx, string name)
{
IExecutionContext module = ctx.CreateChildContext();
ctx.DefineVariable(name, new ConstantVariable(new GenericValue<IExecutionContext>(module)));
return module;
}
示例8: ExecuteSingleIteration
public TerminationReason ExecuteSingleIteration(IExecutionContext context, bool create_child_context)
{
IExecutionContext child_context = create_child_context ? context.CreateChildContext() : context;
try
{
IterationBody.Run(child_context);
}
catch(IterationTermination info)
{
switch(info.Reason)
{
case TerminationReason.Continue:
case TerminationReason.Break:
return info.Reason;
default:
throw info;
}
}
finally
{
if(create_child_context)
child_context.Dispose();
}
return TerminationReason.None;
}
示例9: CreateContext
public static IValue CreateContext(IExecutionContext ctx, IList<IArgument> arguments)
{
var args = CommandUtilities.ManageArguments(arguments)
.Exactly(0)
.Results();
return new GenericValue<IExecutionContext>(ctx.CreateChildContext());
}
示例10: Execute
public static IValue Execute(IExecutionContext ctx, IList<IArgument> arguments)
{
var args = CommandUtilities.ManageArguments(arguments)
.Exactly(1)
.CanConvert<IExecutable>(0)
.Results();
IExecutionContext localCtx = ctx.CreateChildContext();
return localCtx.Execute(args[0].GetValue<IExecutable>(), true);
}
示例11: ifStm
public static IValue ifStm(IExecutionContext ctx, IList<IArgument> arguments)
{
var args = CommandUtilities.ManageArguments(arguments)
.Between(2, 3)
.CanConvert<bool>(0)
.Results();
if(args[0].GetValue<bool>())
{
if (args[1].CanConvert<IExecutable>())
{
IExecutionContext localCtx = ctx.CreateChildContext();
return localCtx.Execute(arguments[1].GetValue().GetValue<IExecutable>());
}
else
{
return args[1];
}
}
else if(args.Length == 3)
{
if (args[2].CanConvert<IExecutable>())
{
IExecutionContext localCtx = ctx.CreateChildContext();
return localCtx.Execute(arguments[2].GetValue().GetValue<IExecutable>());
}
else
{
return args[2];
}
}
return GenericValue<object>.Default;
}