问题描述
在我创建通用查询和结果调用的基础页面中,为了简单起见,我有一个函数可以返回基于 Android 或 iOS 的构建查询。
```public Query QueryById(string searchId)
{
Query tempQuery = null;
if (_onAndroid)
{ tempQuery = x => x.Marked(searchId); }
else if (_oniOS)
{ tempQuery = x => x.Id(searchId); }
else // should never enter here
{ throw new NotSupportedException(); }
return tempQuery;
}```
现在我想扩展这里创建的查询,说添加一个
.Index(2)
甚至抓取该索引下的所有类以抓取原始容器中的信息集合
.Index(3).Class("LabelRenderer")
有什么方法可以进行查询并扩展它。 不是转换为字符串,然后附加所有内容,然后将其放回查询对象中。
感谢您的任何见解!
解决方法
下面的代码可以工作:
var query = app.Query(q => q.Id("searchId")
.Descendant()
.Index(2)
.Class("LabelRenderer"));