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; }