本文整理汇总了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()));
}
}
示例2: Evaluate
public override void Evaluate(IScriptContext context)
{
context.SetItem("Context", context);
context.SetItem("prog", this);
base.Evaluate(context);
}
示例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();
}
示例4: Evaluate
public override void Evaluate(IScriptContext context)
{
if (Name != null)
context.SetItem(Name, this);
context.Result = this;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
示例12: AssignIdentifier
private void AssignIdentifier(object value, IScriptContext context)
{
context.SetItem(Identifier, value);
}
示例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));
}
示例14: Execute
public override int Execute(IScriptContext context)
{
context.SetItem(Id, Machine.AX);
return 1;
}