本文整理汇总了C#中Couchbase.Lite.Database.GetMaxRevTreeDepth方法的典型用法代码示例。如果您正苦于以下问题:C# Database.GetMaxRevTreeDepth方法的具体用法?C# Database.GetMaxRevTreeDepth怎么用?C# Database.GetMaxRevTreeDepth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Couchbase.Lite.Database
的用法示例。
在下文中一共展示了Database.GetMaxRevTreeDepth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePostBody
private IDictionary<string, object> CreatePostBody(IEnumerable<RevisionInternal> revs, Database database)
{
var maxRevTreeDepth = database.GetMaxRevTreeDepth();
Func<RevisionInternal, IDictionary<string, object>> invoke = source =>
{
if(!database.IsOpen) {
return null;
}
//TODO: Deferred attachments
ValueTypePtr<bool> haveBodies = false;
var possibleAncestors = database.Storage.GetPossibleAncestors(source, Puller.MaxAttsSince, haveBodies);
var key = new Dictionary<string, object> {
["id"] = source.DocID,
["rev"] = source.RevID.ToString()
};
if(possibleAncestors != null) {
var bodyKey = haveBodies ? "atts_since" : "revs_from";
key[bodyKey] = possibleAncestors;
} else {
if(source.Generation > maxRevTreeDepth) {
key["revs_limit"] = maxRevTreeDepth;
}
}
return key;
};
// Build up a JSON body describing what revisions we want:
IEnumerable<IDictionary<string, object>> keys = null;
try {
keys = revs.Select(invoke).Where(x => x != null);
} catch(Exception ex) {
Log.To.Sync.E(Tag, "Error generating bulk request data.", ex);
}
var retval = new Dictionary<string, object>();
retval["docs"] = keys;
Log.To.Sync.V(Tag, "Created bulk download request {0}{1}Body: {2}", _bulkGetUri, Environment.NewLine,
new LogJsonString(keys));
return retval;
}