本文整理汇总了C#中Query.EvalList方法的典型用法代码示例。如果您正苦于以下问题:C# Query.EvalList方法的具体用法?C# Query.EvalList怎么用?C# Query.EvalList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query.EvalList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Context
public void Context()
{
Common.Reset();
using (Database database = Database.Get(Common.DatabaseName))
{
Documents docs = Common.Populate(database, "A", "B", "C", "D");
Query query = new Query(database.GetDocument("B"));
IList<object> results = query.EvalList("/*[1]/*[2]");
Assert.AreEqual("BB", ((Element)results[0]).Name);
query.SetContext(results[0]);
results = query.EvalList("./BBB");
Assert.AreEqual(1, results.Count);
Assert.AreEqual("BBB", ((Element)results[0]).Name);
results = query.EvalList("./XYZ");
Assert.AreEqual(0, results.Count);
}
}
示例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]);
}
示例3: TypeConversion
public void TypeConversion()
{
Common.Reset();
TypeConversion(1234);
TypeConversion("string");
TypeConversion(1234.567);
TypeConversion(false);
TypeConversion(DateTime.Now);
TypeConversion(DateTime.UtcNow);
TypeConversion(new TimeSpan(12300000));
TypeConversion(new Decimal(123456789));
TypeConversion(new XmlQualifiedName("foo", "bar"));
// Single dimensional array
Query query = new Query();
object[] arr = new object[] {1, "2", 3.4, true};
query.SetVariable("var", arr);
IList<object> results = query.EvalList("$var");
Assert.AreEqual(4, results.Count);
CollectionAssert.AreEqual(arr, results);
// Multi dimensional array (test flattening)
query = new Query();
arr = new object[] { 1, "2", new object[]{3.4, 5, 6}, true };
query.SetVariable("var", arr);
results = query.EvalList("$var");
Assert.AreEqual(6, results.Count);
CollectionAssert.AreEqual(new object[] { 1, "2", 3.4, 5, 6, true }, results);
}
示例4: MultipleDatabases
public void MultipleDatabases()
{
Common.Reset();
using (Database database = Database.Get(Common.DatabaseName))
{
using (Database database2 = Database.Get(Common.DatabaseName + "2"))
{
Documents docs = Common.Populate(database, "A", "B", "C", "D");
Documents docs2 = Common.Populate(database2, "A", "B", "E", "F");
Query query = new Query(new []{database, database2});
IList<object> results = query.EvalList("/A");
Assert.AreEqual(2, results.Count);
CollectionAssert.AreEquivalent(new[] { Common.DatabaseName, Common.DatabaseName + "2"},
results.OfType<Node>().Select(n => n.Database.Name));
results = query.EvalList("/*");
Assert.AreEqual(8, results.Count);
CollectionAssert.AreEquivalent(docs.Names.Concat(docs2.Names),
results.OfType<Node>().Select(n => n.Name));
}
}
}