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


C# IScriptContext.SetBreak方法代码示例

本文整理汇总了C#中IScriptContext.SetBreak方法的典型用法代码示例。如果您正苦于以下问题:C# IScriptContext.SetBreak方法的具体用法?C# IScriptContext.SetBreak怎么用?C# IScriptContext.SetBreak使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScriptContext的用法示例。


在下文中一共展示了IScriptContext.SetBreak方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Evaluate

 //TODO: reorganize switch
 public override void Evaluate(IScriptContext context)
 {
     switch (operation)
       {
     case "break":
       if (context.Result == null)
     context.Result = RuntimeHost.NullValue;
       context.SetBreak(true);
       break;
     case "continue":
       if (context.Result == null)
     context.Result = RuntimeHost.NullValue;
       context.SetContinue(true);
       break;
     case "return":
       expression.Evaluate(context);
       context.SetReturn(true);
       break;
     case "throw":
       expression.Evaluate(context);
       throw (Exception)context.Result;
     default:
       throw new ScriptException("This should never happen");
       }
 }
开发者ID:2yangk23,项目名称:MapleShark,代码行数:26,代码来源:ScriptFlowControlStatement.cs

示例2: Evaluate

        public override void Evaluate(IScriptContext context)
        {
            bool condBool;
              object result = RuntimeHost.NullValue;

              init.Evaluate(context);
              cond.Evaluate(context);
              condBool = context.Result == null ? true : (bool)context.Result;

              while (condBool)
              {
            statement.Evaluate(context);
            result = context.Result;

            if (context.IsBreak() || context.IsReturn())
            {
              context.SetBreak(false);
              break;
            }

            if (context.IsContinue())
            {
              context.SetContinue(false);
            }

            next.Evaluate(context);
            cond.Evaluate(context);
            condBool = context.Result == null ? true : (bool)context.Result;
              }

              context.Result = result;
        }
开发者ID:Zepheus,项目名称:Fiesta_Utils,代码行数:32,代码来源:ScriptForStatement.cs

示例3: Evaluate

        public override void Evaluate(IScriptContext context)
        {
            condition.Evaluate(context);
              object lastResult = RuntimeHost.NullValue;

              while ((bool)context.Result)
              {
            statement.Evaluate(context);
            lastResult = context.Result;

            if (context.IsBreak() || context.IsReturn())
            {
              context.SetBreak(false);
              break;
            }

            if (context.IsContinue())
            {
              context.SetContinue(false);
            }

            condition.Evaluate(context);
              }

              context.Result = lastResult;
        }
开发者ID:Zepheus,项目名称:Fiesta_Utils,代码行数:26,代码来源:ScriptWhileStatement.cs

示例4: Evaluate

 public override void Evaluate(IScriptContext context)
 {
   var switchValue = context.Result;     
   _cond.Evaluate(context);
   if (switchValue.Equals(context.Result))
   {
     _statement.Evaluate(context);
     context.SetBreak(true);
   }
   else
     context.Result = switchValue;
 }
开发者ID:eightrivers,项目名称:SSharp,代码行数:12,代码来源:ScriptSwitchCaseStatement.cs

示例5: Evaluate

        public override void Evaluate(IScriptContext context)
        {
            foreach (ScriptSwitchCaseStatement caseStatement in cases)
              {
            caseStatement.Evaluate(context);
            if (context.IsBreak() || context.IsReturn())
            {
              context.SetBreak(false);
              return;
            }
              }

              if (defaultCase != null)
            defaultCase.Evaluate(context);
        }
开发者ID:Temperament,项目名称:FiestaShark,代码行数:15,代码来源:ScriptSwitchStatement.cs

示例6: Evaluate

    public override void Evaluate(IScriptContext context)
    {
      var result = RuntimeHost.NullValue;

      //Create local scope
      var scope = RuntimeHost.ScopeFactory.Create(ScopeTypes.Local, context.Scope);
      context.CreateScope(scope);

      try
      {
        _init.Evaluate(context);
        _cond.Evaluate(context);
        bool condBool = context.Result == null ? true : (bool)context.Result;

        while (condBool)
        {
          _statement.Evaluate(context);
          result = context.Result;

          if (context.IsBreak() || context.IsReturn())
          {
            context.SetBreak(false);
            break;
          }

          if (context.IsContinue())
          {
            context.SetContinue(false);
          }


          _next.Evaluate(context);
          _cond.Evaluate(context);
          condBool = context.Result == null ? true : (bool)context.Result;
        }

        context.Result = result;
      }
      finally
      {
        context.RemoveLocalScope();
      }
    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:43,代码来源:ScriptForStatement.cs

示例7: Evaluate

        public override void Evaluate(IScriptContext context)
        {
            expr.Evaluate(context);

              IEnumerable enumeration = context.Result as IEnumerable;
              IEnumerator enumerator = null;

              if (enumeration != null)
              {
            enumerator = enumeration.GetEnumerator();
              }
              else
              {
            IObjectBind bind = RuntimeHost.Binder.BindToMethod(context.Result, "GetEnumerator",new Type[0], new object[0]);
            if (bind != null)
              enumerator = bind.Invoke(context, null) as IEnumerator;
              }

              if (enumerator == null)
            throw new ScriptException("GetEnumerator() method did not found in object: " + context.Result.ToString());

              enumerator.Reset();

              while(enumerator.MoveNext())
              {
            context.SetItem(name.Text, enumerator.Current);
            statement.Evaluate(context);
            if (context.IsBreak() || context.IsReturn())
            {
              context.SetBreak(false);
              break;
            }
            if (context.IsContinue())
            {
              context.SetContinue(false);
            }
              }
        }
开发者ID:2yangk23,项目名称:MapleShark,代码行数:38,代码来源:ScriptForEachStatement.cs

示例8: Invoke

        public object Invoke(IScriptContext context, object[] args)
        {
            activeContext = context;
            object result = RuntimeHost.NullValue;

            INotifyingScope functionScope = (INotifyingScope)RuntimeHost.ScopeFactory.Create(ScopeTypes.Function, context.Scope, context);
            context.CreateScope(functionScope);

            try
            {
              if (Parameters != null)
              {
            context.Result = args;
            Parameters.Evaluate(context);
              }

              functionScope.BeforeSetItem += ScopeBeforeSetItem;

              if (Contract != null)
              {
            functionScope.AfterSetItem += CheckContractInvariant;
            Contract.CheckPre(context);
            Contract.CheckInv(context);
              }

              context.Result = RuntimeHost.NullValue;
              Body.Evaluate(context);
              result = context.Result;

              if (Contract != null)
              {
            functionScope.AfterSetItem -= CheckContractInvariant;
            Contract.CheckInv(context);
            Contract.CheckPost(context);
              }
            }
            finally
            {
              context.RemoveLocalScope();
              context.SetBreak(false);
              context.SetContinue(false);
              context.SetReturn(false);
              context.Result = result;

              functionScope.BeforeSetItem -= ScopeBeforeSetItem;
              activeContext = null;
            }

            return result;
        }
开发者ID:2yangk23,项目名称:MapleShark,代码行数:50,代码来源:ScriptFunctionDefinition.cs

示例9: Evaluate

    public override void Evaluate(IScriptContext context)
    {
      _expr.Evaluate(context);

      if (context.Result == null) throw new NullReferenceException(string.Format(Strings.NullReferenceInCode, Code(context)));

      var enumeration = context.Result as IEnumerable;
      IEnumerator enumerator = null;

      if (enumeration != null)
      {
        enumerator = enumeration.GetEnumerator();
      }
      else
      {
        IBinding bind = RuntimeHost.Binder.BindToMethod(context.Result, "GetEnumerator", new Type[0], new object[0]);
        if (bind != null)
          enumerator = bind.Invoke(context, null) as IEnumerator;
      }

      if (enumerator == null)
        throw new ScriptExecutionException(string.Format(Strings.ForEachMethodNotFound, context.Result));

      enumerator.Reset();

      while (enumerator.MoveNext())
      {
        context.SetItem(_name.Text, enumerator.Current);
        _statement.Evaluate(context);
        if (context.IsBreak() || context.IsReturn())
        {
          context.SetBreak(false);
          break;
        }
        if (context.IsContinue())
        {
          context.SetContinue(false);
        }
      }

    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:41,代码来源:ScriptForEachStatement.cs


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