本文整理汇总了C#中Sprocket.Web.CMS.Script.ExecutionState.HasVariable方法的典型用法代码示例。如果您正苦于以下问题:C# ExecutionState.HasVariable方法的具体用法?C# ExecutionState.HasVariable怎么用?C# ExecutionState.HasVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprocket.Web.CMS.Script.ExecutionState
的用法示例。
在下文中一共展示了ExecutionState.HasVariable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
public object Evaluate(Token contextToken, List<ExpressionArgument> args, ExecutionState state)
{
object o = state.HasVariable(variableToken.Value) ? state.GetVariable(variableToken.Value) : null;
if (o is IArgumentListEvaluatorExpression)
return ((IArgumentListEvaluatorExpression)o).Evaluate(contextToken, args, state);
else
return SystemTypeEvaluator.EvaluateArguments(state, o, args, contextToken);
}
示例2: EvaluateProperty
public object EvaluateProperty(string propertyName, Token token, ExecutionState state)
{
object o = state.HasVariable(variableToken.Value) ? state.GetVariable(variableToken.Value) : null;
if (o is IPropertyEvaluatorExpression)
{
object val = ((IPropertyEvaluatorExpression)o).EvaluateProperty(propertyName, token, state);
if(val != null)
if (val.ToString() == VariableExpression.InvalidProperty)
throw new InstructionExecutionException("\"" + propertyName + "\" is not a valid property of this variable.", token);
return val;
}
else
return SystemTypeEvaluator.EvaluateProperty(o, propertyName, token);
}
示例3: Execute
public void Execute(ExecutionState state)
{
IList list;
if (expr is IListExpression)
list = ((IListExpression)expr).GetList(state);
else
{
list = expr.Evaluate(state, listToken) as IList;
if (list == null)
throw new InstructionExecutionException("\"" + listToken.Value + "\" doesn't contain a list of anything.", listToken);
}
if (state.HasVariable(iteratorToken.Value))
throw new InstructionExecutionException("\"" + iteratorToken.Value + "\" already equates to something else. You should use a different word.", iteratorToken);
foreach (object item in list)
{
state.Variables[iteratorToken.Value] = item;
instructions.Execute(state);
}
state.Variables.Remove(iteratorToken.Value);
}