本文整理汇总了C#中Context.HasVariable方法的典型用法代码示例。如果您正苦于以下问题:C# Context.HasVariable方法的具体用法?C# Context.HasVariable怎么用?C# Context.HasVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context.HasVariable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefineAndHasVariable
public void DefineAndHasVariable()
{
Context context = new Context();
Assert.IsFalse(context.HasVariable("a"));
context.DefineVariable("a");
Assert.IsTrue(context.HasVariable("a"));
Assert.IsNull(context.GetValue("a"));
}
示例2: DefineVariables
public void DefineVariables()
{
Context context = new Context();
EvaluateCommands("var a; int b; double c; String d; bool e;", context);
Assert.IsTrue(context.HasVariable("a"));
Assert.IsTrue(context.HasVariable("b"));
Assert.IsTrue(context.HasVariable("c"));
Assert.IsTrue(context.HasVariable("d"));
Assert.IsTrue(context.HasVariable("e"));
}
示例3: DefineAndHasVariableInParent
public void DefineAndHasVariableInParent()
{
Context parent = new Context();
Context context = new Context(parent);
Assert.IsFalse(parent.HasVariable("a"));
Assert.IsFalse(context.HasVariable("a"));
parent.DefineVariable("a");
Assert.IsTrue(parent.HasVariable("a"));
Assert.IsTrue(context.HasVariable("a"));
Assert.IsNull(context.GetValue("a"));
}
示例4: DefineVariableWithInitialValue
public void DefineVariableWithInitialValue()
{
Context context = new Context();
DefineVariableCommand expr = new DefineVariableCommand(null, "a", new ConstantExpression(1));
Assert.AreEqual(1, expr.Execute(context));
Assert.IsTrue(context.HasVariable("a"));
Assert.AreEqual(1, context.GetValue("a"));
Assert.AreEqual("a", expr.Name);
Assert.IsNull(expr.TypeExpression);
}
示例5: DefineVariableWithTypeAndInitialValue
public void DefineVariableWithTypeAndInitialValue()
{
Context context = new Context();
IExpression typeexpr = new VariableExpression("List");
DefineVariableCommand expr = new DefineVariableCommand(typeexpr, "a", new ConstantExpression(1));
Assert.AreEqual(1, expr.Execute(context));
Assert.IsTrue(context.HasVariable("a"));
Assert.AreEqual(1, context.GetValue("a"));
Assert.AreEqual("a", expr.Name);
Assert.AreEqual(typeexpr, expr.TypeExpression);
}
示例6: DefineTypedVariable
public void DefineTypedVariable()
{
Context context = new Context();
EvaluateCommands("MyModule.MyClass a;", context);
Assert.IsTrue(context.HasVariable("a"));
}