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


C# IScriptContext.SetItem方法代码示例

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


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

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

示例2: Evaluate

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

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

示例3: Evaluate

    public override void Evaluate(IScriptContext context)
    {
      context.SetItem("Context", context);
      context.SetItem("prog", this);
      //Reset flags in context
      context.ResetControlFlags();

      base.Evaluate(context);

      context.ResetControlFlags();
    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:11,代码来源:ScriptProg.cs

示例4: Evaluate

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

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

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

示例6: Evaluate

 public override void Evaluate(IScriptContext context)
 {
   var local = context.Scope as LocalScope;
   if (local != null)
     local.CreateVariable(_identifier, null);
   else
     context.SetItem(_identifier, null);
 }
开发者ID:eightrivers,项目名称:SSharp,代码行数:8,代码来源:ScriptVarExpr.cs

示例7: Evaluate

        public override void Evaluate(IScriptContext context)
        {
            if (context.Result == null) return;

              object[] paramVals = (object[])context.Result;

              for (int index=0; index < paramVals.Length; index++)
            if (index < Identifiers.Count)
            {
              context.SetItem(Identifiers[index], paramVals[index]);
            }

              context.Result = RuntimeHost.NullValue;
        }
开发者ID:2yangk23,项目名称:MapleShark,代码行数:14,代码来源:ScriptFuncParameters.cs

示例8: Evaluate

 public override void Evaluate(IScriptContext context)
 {
     try
       {
     tryBlock.Evaluate(context);
       }
       catch(Exception e)
       {
     context.SetItem(expName, e);
     catchBlock.Evaluate(context);
       }
       finally
       {
     finallyBlock.Evaluate(context);
       }
 }
开发者ID:Temperament,项目名称:FiestaShark,代码行数:16,代码来源:ScriptTryCatchFinallyStatement.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

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

示例11: AssignIdentifier

    private void AssignIdentifier(object value, IScriptContext context)
    {
      if (IsGlobal)
      {
        SetToParentScope(context.Scope.Parent, _identifier, value);
        _variable = null;
        return;
      }

      if (IsVar && ((context.Scope is LocalScope) || (context.Scope is FunctionScope)))
      {
        context.Scope.CreateVariable(_identifier, value);
        return;
      }

      if (_variable != null)
      {
        _variable.Value = value;
      }
      else
      {
        context.SetItem(_identifier, value);
        
        object tmp;
        _variable = CreateRef(_identifier, context, false, out tmp);
      }
    }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:27,代码来源:ScriptQualifiedName.cs

示例12: AssignIdentifier

 private void AssignIdentifier(object value, IScriptContext context)
 {
     context.SetItem(Identifier, value);
 }
开发者ID:kayateia,项目名称:scriptdotnet,代码行数:4,代码来源:ScriptQualifiedName.cs

示例13: Invoke

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

        var rez = RuntimeHost.NullValue;
        try
        {
          rez = _dynamicMethod.Invoke(context, _arguments);
        }
        finally
        {
          context.RemoveLocalScope();
        }

        if (rez != RuntimeHost.NullValue) return rez;
        throw new ScriptExecutionException(string.Format(Strings.DynamicObjectMethodCallError, _scriptable));
      }
开发者ID:eightrivers,项目名称:SSharp,代码行数:19,代码来源:DefaultObjectBinding.cs

示例14: Execute

 public override int Execute(IScriptContext context)
 {
   context.SetItem(Id, Machine.AX);
   return 1;
 }
开发者ID:eightrivers,项目名称:SSharp,代码行数:5,代码来源:ValueOperations.cs


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