本文整理汇总了C#中IScriptContext.RemoveLocalScope方法的典型用法代码示例。如果您正苦于以下问题:C# IScriptContext.RemoveLocalScope方法的具体用法?C# IScriptContext.RemoveLocalScope怎么用?C# IScriptContext.RemoveLocalScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScriptContext
的用法示例。
在下文中一共展示了IScriptContext.RemoveLocalScope方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例2: 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;
}
示例3: 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;
}
示例4: 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
{
context.ResetControlFlags();
_metaProg.Evaluate(context);
return context.Result;
}
finally
{
if (scopeOwner)
context.RemoveLocalScope();
context.ResetControlFlags();
}
}
示例5: Evaluate
public override void Evaluate(IScriptContext context)
{
name.Evaluate(context);
context.CreateScope(RuntimeHost.ScopeFactory.Create(ScopeTypes.Using, context.Scope, context.Result));
statement.Evaluate(context);
context.RemoveLocalScope();
}
示例6: Invoke
public object Invoke(IScriptContext context, object[] args)
{
activeContext = context;
object result = RuntimeHost.NullValue;
INotifyingScope functionScope = (INotifyingScope)RuntimeHost.ScopeFactory.Create(ScopeTypes.Function, context.Scope, context);
context.CreateScope(functionScope);
try
{
if (Parameters != null)
{
context.Result = args;
Parameters.Evaluate(context);
}
functionScope.BeforeSetItem += ScopeBeforeSetItem;
if (Contract != null)
{
functionScope.AfterSetItem += CheckContractInvariant;
Contract.CheckPre(context);
Contract.CheckInv(context);
}
context.Result = RuntimeHost.NullValue;
Body.Evaluate(context);
result = context.Result;
if (Contract != null)
{
functionScope.AfterSetItem -= CheckContractInvariant;
Contract.CheckInv(context);
Contract.CheckPost(context);
}
}
finally
{
context.RemoveLocalScope();
context.SetBreak(false);
context.SetContinue(false);
context.SetReturn(false);
context.Result = result;
functionScope.BeforeSetItem -= ScopeBeforeSetItem;
activeContext = null;
}
return result;
}
示例7: 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()));
}
}
示例8: Evaluate
public override void Evaluate(IScriptContext context)
{
var result = RuntimeHost.NullValue;
//Create local scope
var scope = RuntimeHost.ScopeFactory.Create(ScopeTypes.Local, context.Scope);
context.CreateScope(scope);
try
{
_init.Evaluate(context);
_cond.Evaluate(context);
bool condBool = context.Result == null ? true : (bool)context.Result;
while (condBool)
{
_statement.Evaluate(context);
result = context.Result;
if (context.IsBreak() || context.IsReturn())
{
context.SetBreak(false);
break;
}
if (context.IsContinue())
{
context.SetContinue(false);
}
_next.Evaluate(context);
_cond.Evaluate(context);
condBool = context.Result == null ? true : (bool)context.Result;
}
context.Result = result;
}
finally
{
context.RemoveLocalScope();
}
}
示例9: 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));
}