当前位置: 首页>>代码示例>>C#>>正文


C# IExecutionContext.CreateChildContext方法代码示例

本文整理汇总了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;
        }
开发者ID:redxdev,项目名称:DScript,代码行数:30,代码来源:LoopLibrary.cs

示例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;
        }
开发者ID:langpavel,项目名称:LPS-old,代码行数:11,代码来源:FunctionExpression.cs

示例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;
         }
     }
 }
开发者ID:langpavel,项目名称:LPS-old,代码行数:13,代码来源:ForeachStatement.cs

示例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();
     }
 }
开发者ID:langpavel,项目名称:LPS-old,代码行数:14,代码来源:BlockStatement.cs

示例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);
        }
开发者ID:redxdev,项目名称:DScript,代码行数:16,代码来源:UtilityLibrary.cs

示例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);
        }
开发者ID:redxdev,项目名称:DScript,代码行数:17,代码来源:DictionaryLibrary.cs

示例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;
 }
开发者ID:redxdev,项目名称:DScript,代码行数:6,代码来源:ContextUtilities.cs

示例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;
 }
开发者ID:langpavel,项目名称:LPS-old,代码行数:25,代码来源:LoopStatementBase.cs

示例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());
        }
开发者ID:redxdev,项目名称:DScript,代码行数:8,代码来源:LanguageLibrary.cs

示例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);
        }
开发者ID:redxdev,项目名称:DScript,代码行数:11,代码来源:LanguageLibrary.cs

示例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;
        }
开发者ID:redxdev,项目名称:DScript,代码行数:34,代码来源:ConditionalLibrary.cs


注:本文中的IExecutionContext.CreateChildContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。