本文整理汇总了C#中IScriptContext.SetBreak方法的典型用法代码示例。如果您正苦于以下问题:C# IScriptContext.SetBreak方法的具体用法?C# IScriptContext.SetBreak怎么用?C# IScriptContext.SetBreak使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScriptContext
的用法示例。
在下文中一共展示了IScriptContext.SetBreak方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
//TODO: reorganize switch
public override void Evaluate(IScriptContext context)
{
switch (operation)
{
case "break":
if (context.Result == null)
context.Result = RuntimeHost.NullValue;
context.SetBreak(true);
break;
case "continue":
if (context.Result == null)
context.Result = RuntimeHost.NullValue;
context.SetContinue(true);
break;
case "return":
expression.Evaluate(context);
context.SetReturn(true);
break;
case "throw":
expression.Evaluate(context);
throw (Exception)context.Result;
default:
throw new ScriptException("This should never happen");
}
}
示例2: Evaluate
public override void Evaluate(IScriptContext context)
{
bool condBool;
object result = RuntimeHost.NullValue;
init.Evaluate(context);
cond.Evaluate(context);
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;
}
示例3: Evaluate
public override void Evaluate(IScriptContext context)
{
condition.Evaluate(context);
object lastResult = RuntimeHost.NullValue;
while ((bool)context.Result)
{
statement.Evaluate(context);
lastResult = context.Result;
if (context.IsBreak() || context.IsReturn())
{
context.SetBreak(false);
break;
}
if (context.IsContinue())
{
context.SetContinue(false);
}
condition.Evaluate(context);
}
context.Result = lastResult;
}
示例4: Evaluate
public override void Evaluate(IScriptContext context)
{
var switchValue = context.Result;
_cond.Evaluate(context);
if (switchValue.Equals(context.Result))
{
_statement.Evaluate(context);
context.SetBreak(true);
}
else
context.Result = switchValue;
}
示例5: Evaluate
public override void Evaluate(IScriptContext context)
{
foreach (ScriptSwitchCaseStatement caseStatement in cases)
{
caseStatement.Evaluate(context);
if (context.IsBreak() || context.IsReturn())
{
context.SetBreak(false);
return;
}
}
if (defaultCase != null)
defaultCase.Evaluate(context);
}
示例6: 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();
}
}
示例7: 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);
}
}
}
示例8: 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;
}
示例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);
}
}
}