当前位置: 首页>>代码示例>>C#>>正文


C# Body.GetPropertyForKey方法代码示例

本文整理汇总了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;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:7,代码来源:RevisionInternal.cs

示例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;
        }
开发者ID:wilsondy,项目名称:couchbase-lite-net,代码行数:50,代码来源:DocumentMethods.cs

示例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;
 }
开发者ID:FireflyLogic,项目名称:couchbase-lite-net,代码行数:5,代码来源:RevisionInternal.cs

示例4: RevisionInternal

 internal RevisionInternal(Body body)
     : this(body.GetPropertyForKey<string>("_id"), body.GetPropertyForKey<string>("_rev"), body.GetPropertyForKey<bool>("_deleted"))
 {
     this._body = body;
 }
开发者ID:JackWangCUMT,项目名称:couchbase-lite-net,代码行数:5,代码来源:RevisionInternal.cs

示例5: IsValid

 public static bool IsValid(Body body)
 {
     return body.GetPropertyForKey("_id") != null ||
     (body.GetPropertyForKey("_rev") == null && body.GetPropertyForKey("_deleted") == null);
 }
开发者ID:JackWangCUMT,项目名称:couchbase-lite-net,代码行数:5,代码来源:RevisionInternal.cs


注:本文中的Couchbase.Lite.Internal.Body.GetPropertyForKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。