本文整理汇总了C#中Query.SetVariable方法的典型用法代码示例。如果您正苦于以下问题:C# Query.SetVariable方法的具体用法?C# Query.SetVariable怎么用?C# Query.SetVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query.SetVariable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypeConversion
private void TypeConversion(object value)
{
Query query = new Query();
query.SetVariable("var", value);
IList<object> results = query.EvalList("$var");
Assert.AreEqual(1, results.Count);
Assert.AreEqual(value, results[0]);
}
示例2: Externals
public void Externals()
{
Common.Reset();
// External static method call
Query query = new Query();
query.SetExternal(GetType());
IList<object> results = query.EvalList("QueryTest:FuncTest(xs:int(5))");
Assert.AreEqual(1, results.Count);
Assert.AreEqual(FuncTest(5), results[0]);
// External class construction and member call
query = new Query();
query.SetExternal(typeof(ExtTest));
results = query.EvalList("let $cls := ExtTest:new('testing') return ExtTest:Count($cls, xs:int(5))");
Assert.AreEqual(1, results.Count);
Assert.AreEqual(12, results[0]);
// Passing an object via variable binding
query = new Query();
query.SetVariable("var", new ExtTest("testing"));
query.SetExternal(GetType());
results = query.EvalList("QueryTest:BindingTest($var, xs:int(5))");
Assert.AreEqual(1, results.Count);
Assert.AreEqual(12, results[0]);
}