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


C# IContext.SetValue方法代码示例

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


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

示例1: Execute

        public void Execute(IContext context)
        {
            Module module = ModuleUtilities.LoadModule(this.modname, context);

            if (this.names != null)
                foreach (string name in this.names)
                    context.SetValue(name, module.GetValue(name));
            else
                foreach (string name in module.GetNames())
                    context.SetValue(name, module.GetValue(name));
        }
开发者ID:ajlopez,项目名称:PythonSharp,代码行数:11,代码来源:ImportFromCommand.cs

示例2: Execute

        public void Execute(IContext context)
        {
            var environment = context as BindingEnvironment;
            var value = this.expression.Evaluate(context);
            var items = value as IEnumerable;

            if (items == null)
                throw new TypeError(string.Format("'{0}' object is not iterable", Types.GetTypeName(value)));

            foreach (var item in items)
            {
                context.SetValue(this.name, item);
                this.command.Execute(context);
                if (environment != null)
                {
                    if (environment.HasReturnValue())
                        return;

                    if (environment.WasBreak)
                    {
                        environment.WasBreak = false;
                        break;
                    }

                    if (environment.WasContinue)
                        environment.WasContinue = false;
                }
            }
        }
开发者ID:jose2190,项目名称:PythonSharp,代码行数:29,代码来源:ForCommand.cs

示例3: Execute

 public void Execute(IContext context)
 {
     foreach (object result in (IEnumerable)this.expression.Evaluate(context))
     {
         context.SetValue(this.name, result);
         this.command.Execute(context);
     }
 }
开发者ID:ajlopez,项目名称:AjScript,代码行数:8,代码来源:ForEachCommand.cs

示例4: Evaluate

 public object Evaluate(IContext context)
 {
     object value = new Function(this.parameterNames, this.body, context);
     if (this.name != null)
     {
         context.DefineVariable(this.name);
         context.SetValue(this.name, value);
     }
     return value;
 }
开发者ID:tario,项目名称:AjScript-migrated,代码行数:10,代码来源:FunctionExpression.cs

示例5: ResolveToDictionary

        private static IDictionary ResolveToDictionary(VariableExpression expression, IContext context)
        {
            string name = expression.Name;

            object obj = context.GetValue(name);

            if (obj == null || obj == Undefined.Instance)
            {
                obj = new Hashtable();

                // TODO Review if Local or not
                context.SetValue(name, obj);
            }

            return (IDictionary)obj;
        }
开发者ID:ajlopez,项目名称:AjScript,代码行数:16,代码来源:ExpressionUtilities.cs

示例6: Execute

        public void Execute(IContext context)
        {
            BindingEnvironment env = new BindingEnvironment(context);
            IList<IType> bases = null;

            if (this.baseExpressions != null && this.baseExpressions.Count > 0)
            {
                bases = new List<IType>();

                foreach (var expr in this.baseExpressions)
                    bases.Add((IType)expr.Evaluate(context));
            }

            DefinedClass klass = new DefinedClass(this.name, bases, context);
            this.body.Execute(klass);
            foreach (var name in env.GetNames())
            {
                var value = env.GetValue(name);
                var deffunc = value as DefinedFunction;

                if (deffunc != null)
                    klass.SetMethod(deffunc.Name, deffunc);
            }

            klass.SetValue("__doc__", this.doc);

            context.SetValue(this.name, klass);
        }
开发者ID:ajlopez,项目名称:PythonSharp,代码行数:28,代码来源:ClassCommand.cs

示例7: SetValue

 private static void SetValue(VariableExpression expression, object value, IContext context)
 {
     context.SetValue(expression.Name, value);
 }
开发者ID:ajlopez,项目名称:AjScript,代码行数:4,代码来源:ExpressionUtilities.cs

示例8: ResolveToObject

        private static object ResolveToObject(VariableExpression expression, IContext context)
        {
            string name = expression.Name;

            object obj = context.GetValue(name);

            if (obj == null || obj == Undefined.Instance)
            {
                obj = new DynamicObject();

                // TODO Review if Local or not
                context.SetValue(name, obj);
            }

            return obj;
        }
开发者ID:ajlopez,项目名称:AjScript,代码行数:16,代码来源:ExpressionUtilities.cs

示例9: Execute

 public void Execute(IContext context)
 {
     context.SetValue(this.target, this.expression.Evaluate(context));
 }
开发者ID:ajlopez,项目名称:PythonSharp,代码行数:4,代码来源:SetCommand.cs

示例10: Execute

 public void Execute(IContext context)
 {
     object value = this.expression.Evaluate(context);
     context.SetValue(this.name, value);
 }
开发者ID:ajlopez,项目名称:AjScript,代码行数:5,代码来源:SetVariableCommand.cs


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