• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IScriptContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Evaluate

    //TODO: Refactor
    public override void Evaluate(IScriptContext context)
    {
      if (ChildNodes.Count == 0) return;

      //Create local scope
      if (ShouldCreateScope)
      {
        IScriptScope scope = RuntimeHost.ScopeFactory.Create(ScopeTypes.Local, context.Scope);
        context.CreateScope(scope);
      }

      try
      {
        int index = 0;
        while (index < ChildNodes.Count)
        {
          var node = (ScriptAst)ChildNodes[index];
          node.Evaluate(context);

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

          index++;
        }
      }
      finally
      {
        if (ShouldCreateScope)
          context.RemoveLocalScope();
      }
    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:34,代码来源:ScriptCompoundStatement.cs


示例2: Evaluate

    public override void Evaluate(IScriptContext context)
    {
      bool result = true;
      if (list == null)
      {
        context.Result = true;
        return;
      }

      list.Evaluate(context);

      object[] rez = (object[])context.Result;
      foreach (object o in rez)
      {
        try
        {
          result = result & (bool)o;
        }
        catch
        {
          throw new ScriptException("Non boolean expression in post condition");
        }
      }

      context.Result = result;
    }
开发者ID:PantsIsTaken,项目名称:MapleShark,代码行数:26,代码来源:ScriptFuncContractPost.cs


示例3: Evaluate

    public override void Evaluate(IScriptContext context)
    {
      if (context.Scope == null)
        throw new ScriptExecutionException("Null scope");

      context.Scope.CreateVariable(_identifier, null);
    }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:7,代码来源:ScriptVarExpr.cs


示例4: 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


示例5: Evaluate

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

              IObjectBind call = (IObjectBind)context.Result;
              context.Result = RuntimeHost.Activator.CreateInstance(context, call);
        }
开发者ID:Temperament,项目名称:FiestaShark,代码行数:7,代码来源:ScriptNewStmt.cs


示例6: PyProcessContext

 public PyProcessContext(IScriptContext scriptContext,
     dynamic processHandler,
     ProcessFactory processFactory,
     string command,
     string commandArguments,
     string workingDirectory,
     ICommandParameters commandParameters)
 {
     _commandParameters = commandParameters;
     _scriptContext = scriptContext;
     _command = command;
     _commandArguments = commandArguments;
     _workingDirectory = workingDirectory;
     _processFactory = processFactory;
     var processContext = _processFactory.CreateProcessContext(command,
         commandArguments,
         workingDirectory);
     _processHandler = processHandler;
     processContext.OnMessage += (message) =>
     {
         _processHandler.OnMessage(message);
         //  Console.WriteLine(message);
     };
     processContext.OnError += (message) =>
     {
         _processHandler.OnError(message);
     };
     _processHandler.OnInit(this, _commandParameters);
     _processContext = processContext;
 }
开发者ID:ksoysal,项目名称:Projects,代码行数:30,代码来源:PyRunner.cs


示例7: Invoke

        public object Invoke(IScriptContext context, object[] args)
        {
            bool scopeOwner = false;

              if (args != null)
              {
            if (args.Length > 1) throw new ArgumentException("Number of arguments ");
            if (args.Length == 1)
            {
              var assigner = args[0] as ISupportAssign;
              if (assigner == null) throw new NotSupportedException("Given type of argument is not supported");
              assigner.AssignTo(context.CreateScope());
              scopeOwner = true;
            }
              }

              try
              {
            _metaProg.Evaluate(context);
            return context.Result;
              }
              finally
              {
            if (scopeOwner)
              context.RemoveLocalScope();
              }
        }
开发者ID:DenisVuyka,项目名称:SSharp,代码行数:27,代码来源:ScriptMetaExpr.cs


示例8: CheckPre

 public void CheckPre(IScriptContext context)
 {
     if (!CheckCondition(pre, context))
       {
     throw new ScriptVerificationException("Pre condition for function call failed");
       }
 }
开发者ID:Temperament,项目名称:FiestaShark,代码行数:7,代码来源:ScriptFuncContract.cs


示例9: Invoke

    public object Invoke(IScriptContext context, object[] args)
    {
        var functionScope = (INotifyingScope)RuntimeHost.ScopeFactory.Create(ScopeTypes.Function, context.Scope, context);
        context.CreateScope(functionScope);

        Expando values=args.FirstOrDefault() as Expando;
        if (values != null) {
            foreach (var field in values.Fields) {
                context.SetItem(field, values[field]);
            }
        } else {
            if (args.Length > 0)
                throw new ScriptExecutionException("Wrong type of arguments passed to Program Invokation");
        }

        try {
            Evaluate(context);
        }
        finally {
            context.RemoveLocalScope();
            context.ResetControlFlags();
        }

        return context.Result;
    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:25,代码来源:ScriptProg.cs


示例10: CheckInv

 public void CheckInv(IScriptContext context)
 {
     if (!CheckCondition(inv, context))
       {
     throw new ScriptVerificationException("Invariant for function call failed");
       }
 }
开发者ID:Temperament,项目名称:FiestaShark,代码行数:7,代码来源:ScriptFuncContract.cs


示例11: Evaluate

        public override void Evaluate(IScriptContext context)
        {
            // ( Expr )
              if (typeExpr == null)
              {
            expr.Evaluate(context);
              }
              // (Type) Expr
              else
              {
            typeExpr.Evaluate(context);

            Type type = context.Result as Type;
            if (type == null)
            {
              //NOTE: Handling special case of unary minus operator:
              //      (3+2)-2;
              ScriptUnaryExpr unary = expr as ScriptUnaryExpr;

              if (unary == null || unary.OperationSymbol != "-")
            throw new ScriptException("Wrong type expression!");

              //NOTE: expr + (unary expr)
              object left = context.Result;
              unary.Evaluate(context);
              context.Result = @operator.Evaluate(left, context.Result);
              return;
            }

            expr.Evaluate(context);
            context.Result = RuntimeHost.Binder.ConvertTo(context.Result, type);
              }
        }
开发者ID:Temperament,项目名称:FiestaShark,代码行数:33,代码来源:ScriptTypeConvertExpr.cs


示例12: Invoke

            public object Invoke(IScriptContext context, object[] args)
            {
                context.CreateScope();
                context.SetItem("me", scriptable.Instance);
                context.SetItem("body", scriptable);

                object rez = RuntimeHost.NullValue;
                try
                {
                  rez = dynamicMethod.Invoke(context, arguments);
                }
                finally
                {
                  context.RemoveLocalScope();
                }

                if (rez != RuntimeHost.NullValue)
                {
                  return rez;
                }
                else
                {
                  throw new ScriptException(string.Format("Dynamic method call failed in object {0}", scriptable.ToString()));
                }
            }
开发者ID:2yangk23,项目名称:MapleShark,代码行数:25,代码来源:ObjectBinderExtended.cs


示例13: 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


示例14: Evaluate

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

      var call = (IBinding)context.Result;
      context.Result = RuntimeHost.Activator.CreateInstance(context, call);
    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:7,代码来源:ScriptNewStmt.cs


示例15: HandleOperatorArgs

 public HandleOperatorArgs(IScriptContext context, string symbol, object[] arguments)
 {
     Symbol = symbol;
       Arguments = arguments;
       Context = context;
       Cancel = false;
 }
开发者ID:Temperament,项目名称:FiestaShark,代码行数:7,代码来源:IOperatorHandler.cs


示例16: Evaluate

        public override void Evaluate(IScriptContext context)
        {
            if (TypeExpr == null && GenericsPostfix == null)
              {
            context.Result = RuntimeHost.GetType(Identifier);
            return;
              }

              if (TypeExpr != null)
              {
            string name = string.Format("{0}.{1}", EvaluateName(TypeExpr), Identifier);
            Type type = null;

            if (GenericsPostfix != null)
            {
              Type genericType = RuntimeHost.GetType(GenericsPostfix.GetGenericTypeName(name));
              GenericsPostfix.Evaluate(context);
              type = genericType.MakeGenericType((Type[])context.Result);
            }
            else
            {
              type = RuntimeHost.GetType(name);
            }

            context.Result = type;
              }
              else
              {
            Type genericType = RuntimeHost.GetType(Identifier);
            GenericsPostfix.Evaluate(context);
            context.Result = genericType.MakeGenericType((Type[])context.Result);
              }
        }
开发者ID:Zepheus,项目名称:Fiesta_Utils,代码行数:33,代码来源:ScriptTypeExpr.cs


示例17: Evaluate

        public override void Evaluate(IScriptContext context)
        {
            context.SetItem("Context", context);
              context.SetItem("prog", this);

              base.Evaluate(context);
        }
开发者ID:Temperament,项目名称:FiestaShark,代码行数:7,代码来源:ScriptProg.cs


示例18: Evaluate

    public override void Evaluate(IScriptContext context)
    {
      bool result = true;

      if (_list == null)
      {
        context.Result = true;
        return;
      }

      _list.Evaluate(context);
      var rez = (object[])context.Result;

      foreach (var o in rez)
      {
        try
        {
          result = result & (bool)o;
        }
        catch
        {
          throw new ScriptVerificationException(Strings.VerificationNonBoolean);
        }
      }

      context.Result = result;
    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:27,代码来源:ScriptFuncContractPre.cs


示例19: Evaluate

        public override void Evaluate(IScriptContext context)
        {
            if (Name != null)
            context.SetItem(Name, this);

              context.Result = this;
        }
开发者ID:2yangk23,项目名称:MapleShark,代码行数:7,代码来源:ScriptFunctionDefinition.cs


示例20: Invoke

        public object Invoke(IScriptContext context, object[] args)
        {
            string code = (String)args[0];
              ScriptAst result = null;

              LanguageCompiler compiler = (LanguageCompiler) context.GetItem("Compiler", true);
              RuntimeHost.Lock();

              try
              {
            result = Script.Parse(code + ";", false) as ScriptAst;
            //TODO: Create LocalOnlyScope that can't change Parent's variables
            //No, need for doing these. It is already done
            context.CreateScope();
              }
              finally
              {
            RuntimeHost.UnLock();
              }

              result.Evaluate(context);
              context.RemoveLocalScope();

              return context.Result;
        }
开发者ID:Temperament,项目名称:FiestaShark,代码行数:25,代码来源:EvalFunc.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IScriptEngine类代码示例发布时间:2022-05-24
下一篇:
C# IScript类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap