本文整理汇总了C#中Couchbase.Lite.Internal.Body.GetPropertyForKey方法的典型用法代码示例。如果您正苦于以下问题:C# Body.GetPropertyForKey方法的具体用法?C# Body.GetPropertyForKey怎么用?C# Body.GetPropertyForKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Couchbase.Lite.Internal.Body
的用法示例。
在下文中一共展示了Body.GetPropertyForKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RevisionInternal
public RevisionInternal(Body body, Database database) : this((string)body.GetPropertyForKey
("_id"), (string)body.GetPropertyForKey("_rev"), (((bool)body.GetPropertyForKey(
"_deleted") != null) && ((bool)body.GetPropertyForKey("_deleted") == true)), database
)
{
this.body = body;
}
示例2: UpdateDb
// Perform a document operation on the specified database
private static CouchbaseLiteResponse UpdateDb(ICouchbaseListenerContext context, Database db, string docId, Body body, bool deleting)
{
var response = context.CreateResponse();
if (docId != null) {
// On PUT/DELETE, get revision ID from either ?rev= query, If-Match: header, or doc body:
string revParam = context.GetQueryParam("rev");
string ifMatch = context.RequestHeaders["If-Match"];
if (ifMatch != null) {
if (revParam == null) {
revParam = ifMatch;
} else if (!revParam.Equals(ifMatch)) {
return context.CreateResponse(StatusCode.BadRequest);
}
}
if (revParam != null && body != null) {
var revProp = body.GetPropertyForKey("_rev");
if (revProp == null) {
// No _rev property in body, so use ?rev= query param instead:
var props = body.GetProperties();
props["_rev"] = revParam;
body = new Body(props);
} else if (!revProp.Equals(revParam)) {
return context.CreateResponse(StatusCode.BadRequest); // mismatch between _rev and rev
}
}
}
RevisionInternal rev;
StatusCode status = UpdateDocument(context, db, docId, body, deleting, false, out rev);
if ((int)status < 300) {
context.CacheWithEtag(rev.GetRevId()); // set ETag
if (!deleting) {
var url = context.RequestUrl;
if (docId != null) {
response["Location"] = url.AbsoluteUri;
}
}
response.JsonBody = new Body(new Dictionary<string, object> {
{ "ok", true },
{ "id", rev.GetDocId() },
{ "rev", rev.GetRevId() }
});
}
response.InternalStatus = status;
return response;
}
示例3: RevisionInternal
public RevisionInternal(Body body, Database database)
: this((string)body.GetPropertyForKey("_id"), (string)body.GetPropertyForKey("_rev"), (body.HasValueForKey("_deleted") && (bool)body.GetPropertyForKey("_deleted")), database)
{
this.body = body;
}
示例4: RevisionInternal
internal RevisionInternal(Body body)
: this(body.GetPropertyForKey<string>("_id"), body.GetPropertyForKey<string>("_rev"), body.GetPropertyForKey<bool>("_deleted"))
{
this._body = body;
}
示例5: IsValid
public static bool IsValid(Body body)
{
return body.GetPropertyForKey("_id") != null ||
(body.GetPropertyForKey("_rev") == null && body.GetPropertyForKey("_deleted") == null);
}