本文整理汇总了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));
}
示例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;
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例7: SetValue
private static void SetValue(VariableExpression expression, object value, IContext context)
{
context.SetValue(expression.Name, value);
}
示例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;
}
示例9: Execute
public void Execute(IContext context)
{
context.SetValue(this.target, this.expression.Evaluate(context));
}
示例10: Execute
public void Execute(IContext context)
{
object value = this.expression.Evaluate(context);
context.SetValue(this.name, value);
}