• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Internal.RevisionInternal类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Couchbase.Lite.Internal.RevisionInternal的典型用法代码示例。如果您正苦于以下问题:C# RevisionInternal类的具体用法?C# RevisionInternal怎么用?C# RevisionInternal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RevisionInternal类属于Couchbase.Lite.Internal命名空间,在下文中一共展示了RevisionInternal类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DocumentChange

 internal DocumentChange(RevisionInternal addedRevision, RevisionInternal winningRevision, bool isConflict, Uri sourceUrl)
 {
     AddedRevision = addedRevision;
     WinningRevision = winningRevision;
     IsConflict = isConflict;
     SourceUrl = sourceUrl;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:7,代码来源:DocumentChange.cs


示例2: TestChangeNotification

        public void TestChangeNotification()
        {
            var changeNotifications = 0;

            EventHandler<DatabaseChangeEventArgs> handler
                = (sender, e) => changeNotifications++;

            database.Changed += handler;

            // create a document
            var documentProperties = new Dictionary<string, object>();
            documentProperties["foo"] = 1;
            documentProperties["bar"] = false;
            documentProperties["baz"] = "touch";
            
            var body = new Body(documentProperties);
            var rev1 = new RevisionInternal(body, database);
            
            var status = new Status();
            database.PutRevision(rev1, null, false, status);
            
            Assert.AreEqual(1, changeNotifications);

            // Analysis disable once DelegateSubtraction
            database.Changed -= handler;
        }
开发者ID:FireflyLogic,项目名称:couchbase-lite-net,代码行数:26,代码来源:ChangesTest.cs


示例3: TestChangeNotification

        public void TestChangeNotification()
        {
            var countDown = new CountdownEvent(1);
            EventHandler<DatabaseChangeEventArgs> handler
                = (sender, e) => countDown.Signal();

            database.Changed += handler;

            // create a document
            var documentProperties = new Dictionary<string, object>();
            documentProperties["foo"] = 1;
            documentProperties["bar"] = false;
            documentProperties["baz"] = "touch";
            
            var body = new Body(documentProperties);
            var rev1 = new RevisionInternal(body);

            database.PutRevision(rev1, null, false);
            Sleep(500);
            
            Assert.IsTrue(countDown.Wait(TimeSpan.FromSeconds(1)));

            // Analysis disable once DelegateSubtraction
            database.Changed -= handler;
        }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:25,代码来源:ChangesTest.cs


示例4: Run

 public bool Run()
 {
     string[] bigObj = new string[this._enclosing.GetSizeOfDocument()];
     for (int i = 0; i < this._enclosing.GetSizeOfDocument(); i++)
     {
         bigObj[i] = Test10_DeleteDB._propertyValue;
     }
     for (int i_1 = 0; i_1 < this._enclosing.GetNumberOfDocuments(); i_1++)
     {
         //create a document
         IDictionary<string, object> props = new Dictionary<string, object>();
         props.Put("bigArray", bigObj);
         Body body = new Body(props);
         RevisionInternal rev1 = new RevisionInternal(body, this._enclosing.database);
         Status status = new Status();
         try
         {
             rev1 = this._enclosing.database.PutRevision(rev1, null, false, status);
         }
         catch (Exception t)
         {
             Log.E(Test10_DeleteDB.Tag, "Document create failed", t);
             return false;
         }
     }
     return true;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:27,代码来源:Test10_DeleteDB.cs


示例5: ValidationContextImpl

		internal ValidationContextImpl(Database database, RevisionInternal currentRevision
			, RevisionInternal newRev)
		{
			this.database = database;
			this.currentRevision = currentRevision;
			this.newRev = newRev;
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:7,代码来源:ValidationContext.cs


示例6: TestLoadRevisionBody

		// Reproduces issue #167
		// https://github.com/couchbase/couchbase-lite-android/issues/167
		/// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
		public virtual void TestLoadRevisionBody()
		{
			Document document = database.CreateDocument();
			IDictionary<string, object> properties = new Dictionary<string, object>();
			properties.Put("foo", "foo");
			properties.Put("bar", false);
			document.PutProperties(properties);
			NUnit.Framework.Assert.IsNotNull(document.GetCurrentRevision());
			bool deleted = false;
			RevisionInternal revisionInternal = new RevisionInternal(document.GetId(), document
				.GetCurrentRevisionId(), deleted, database);
			EnumSet<Database.TDContentOptions> contentOptions = EnumSet.Of(Database.TDContentOptions
				.TDIncludeAttachments, Database.TDContentOptions.TDBigAttachmentsFollow);
			database.LoadRevisionBody(revisionInternal, contentOptions);
			// now lets purge the document, and then try to load the revision body again
			NUnit.Framework.Assert.IsTrue(document.Purge());
			bool gotExpectedException = false;
			try
			{
				database.LoadRevisionBody(revisionInternal, contentOptions);
			}
			catch (CouchbaseLiteException e)
			{
				if (e.GetCBLStatus().GetCode() == Status.NotFound)
				{
					gotExpectedException = true;
				}
			}
			NUnit.Framework.Assert.IsTrue(gotExpectedException);
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:33,代码来源:DocumentTest.cs


示例7: DocumentChange

 internal DocumentChange(RevisionInternal addedRevision, RevisionInternal winningRevision
     , bool isConflict, Uri sourceUrl)
 {
     this.addedRevision = addedRevision;
     this.winningRevision = winningRevision;
     this.isConflict = isConflict;
     this.sourceUrl = sourceUrl;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:8,代码来源:DocumentChange.cs


示例8: PutDoc

		/// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
		private RevisionInternal PutDoc(Database db, IDictionary<string, object> props)
		{
			RevisionInternal rev = new RevisionInternal(props, db);
			Status status = new Status();
			rev = db.PutRevision(rev, null, false, status);
			NUnit.Framework.Assert.IsTrue(status.IsSuccessful());
			return rev;
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:9,代码来源:ViewsTest.cs


示例9: TestForceInsertEmptyHistory

        public void TestForceInsertEmptyHistory()
        {
            var rev = new RevisionInternal("FakeDocId", "1-abcd".AsRevID(), false);
            var revProperties = new Dictionary<string, object>();
            revProperties.SetDocRevID(rev.DocID, rev.RevID);
            revProperties["message"] = "hi";
            rev.SetProperties(revProperties);

            IList<RevisionID> revHistory = null;
            database.ForceInsert(rev, revHistory, null);
        }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:11,代码来源:RevTreeTest.cs


示例10: TestForceInsertEmptyHistory

        public void TestForceInsertEmptyHistory()
        {
            var rev = new RevisionInternal("FakeDocId", "1-abcd", false);
            var revProperties = new Dictionary<string, object>();
            revProperties.Put("_id", rev.GetDocId());
            revProperties.Put("_rev", rev.GetRevId());
            revProperties["message"] = "hi";
            rev.SetProperties(revProperties);

            IList<string> revHistory = null;
            database.ForceInsert(rev, revHistory, null);
        }
开发者ID:JackWangCUMT,项目名称:couchbase-lite-net,代码行数:12,代码来源:RevTreeTest.cs


示例11: TestForceInsertEmptyHistory

		/// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
		public virtual void TestForceInsertEmptyHistory()
		{
			IList<string> revHistory = null;
			RevisionInternal rev = new RevisionInternal("FakeDocId", "1-tango", false, database
				);
			IDictionary<string, object> revProperties = new Dictionary<string, object>();
			revProperties.Put("_id", rev.GetDocId());
			revProperties.Put("_rev", rev.GetRevId());
			revProperties.Put("message", "hi");
			rev.SetProperties(revProperties);
			database.ForceInsert(rev, revHistory, null);
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:13,代码来源:RevTreeTest.cs


示例12: QueryRow

 internal QueryRow(string documentId, long sequence, object key, object value, RevisionInternal revision, IQueryRowStore storage)
 {
     // Don't initialize _database yet. I might be instantiated on a background thread (if the
     // query is async) which has a different CBLDatabase instance than the original caller.
     // Instead, the database property will be filled in when I'm added to a CBLQueryEnumerator.
     SourceDocumentId = documentId;
     SequenceNumber = sequence;
     _key = key;
     _value = value;
     _documentRevision = revision;
     _storage = storage;
 }
开发者ID:ertrupti9,项目名称:couchbase-lite-net,代码行数:12,代码来源:QueryRow.cs


示例13: TestChangeNotification

		/// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
		public virtual void TestChangeNotification()
		{
			// add listener to database
            database.Changed += (sender, e) => changeNotifications++;
			// create a document
			IDictionary<string, object> documentProperties = new Dictionary<string, object>();
			documentProperties["foo"] = 1;
			documentProperties["bar"] = false;
			documentProperties["baz"] = "touch";
			Body body = new Body(documentProperties);
			RevisionInternal rev1 = new RevisionInternal(body, database);
			Status status = new Status();
			rev1 = database.PutRevision(rev1, null, false, status);
			NUnit.Framework.Assert.AreEqual(1, changeNotifications);
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:16,代码来源:ChangesTest.cs


示例14: TestChangeNotification

		/// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
		public virtual void TestChangeNotification()
		{
			Database.ChangeListener changeListener = new _ChangeListener_16(this);
			// add listener to database
			database.AddChangeListener(changeListener);
			// create a document
			IDictionary<string, object> documentProperties = new Dictionary<string, object>();
			documentProperties.Put("foo", 1);
			documentProperties.Put("bar", false);
			documentProperties.Put("baz", "touch");
			Body body = new Body(documentProperties);
			RevisionInternal rev1 = new RevisionInternal(body, database);
			Status status = new Status();
			rev1 = database.PutRevision(rev1, null, false, status);
			NUnit.Framework.Assert.AreEqual(1, changeNotifications);
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:17,代码来源:ChangesTest.cs


示例15: TestLoadDBPerformance

 /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
 public virtual void TestLoadDBPerformance()
 {
     long startMillis = Runtime.CurrentTimeMillis();
     string[] bigObj = new string[GetSizeOfDocument()];
     for (int i = 0; i < GetSizeOfDocument(); i++)
     {
         bigObj[i] = _propertyValue;
     }
     for (int j = 0; j < GetNumberOfShutAndReloadCycles(); j++)
     {
         //Force close and reopen of manager and database to ensure cold
         //start before doc creation
         try
         {
             TearDown();
             manager = new Manager(new LiteTestContext(), Manager.DefaultOptions);
             database = manager.GetExistingDatabase(DefaultTestDb);
         }
         catch (Exception ex)
         {
             Log.E(Tag, "DB teardown", ex);
             Fail();
         }
         for (int k = 0; k < GetNumberOfDocuments(); k++)
         {
             //create a document
             IDictionary<string, object> props = new Dictionary<string, object>();
             props.Put("bigArray", bigObj);
             Body body = new Body(props);
             RevisionInternal rev1 = new RevisionInternal(body, database);
             Status status = new Status();
             try
             {
                 rev1 = database.PutRevision(rev1, null, false, status);
             }
             catch (Exception t)
             {
                 Log.E(Tag, "Document creation failed", t);
                 Fail();
             }
         }
     }
     Log.V("PerformanceStats", Tag + "," + Sharpen.Extensions.ValueOf(Runtime.CurrentTimeMillis
         () - startMillis).ToString() + "," + GetNumberOfDocuments() + "," + GetSizeOfDocument
         () + ",," + GetNumberOfShutAndReloadCycles());
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:47,代码来源:Test9_LoadDB.cs


示例16: TestCreateDocsUnoptimizedWayPerformance

 /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
 public virtual void TestCreateDocsUnoptimizedWayPerformance()
 {
     long startMillis = Runtime.CurrentTimeMillis();
     string[] bigObj = new string[GetSizeOfDocument()];
     for (int i = 0; i < GetSizeOfDocument(); i++)
     {
         bigObj[i] = _propertyValue;
     }
     for (int i_1 = 0; i_1 < GetNumberOfDocuments(); i_1++)
     {
         //create a document
         IDictionary<string, object> props = new Dictionary<string, object>();
         props.Put("bigArray", bigObj);
         Body body = new Body(props);
         RevisionInternal rev1 = new RevisionInternal(body, database);
         Status status = new Status();
         rev1 = database.PutRevision(rev1, null, false, status);
     }
     Log.V("PerformanceStats", Tag + "," + Sharpen.Extensions.ValueOf(Runtime.CurrentTimeMillis
         () - startMillis).ToString() + "," + GetNumberOfDocuments() + "," + GetSizeOfDocument
         ());
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:23,代码来源:Test2_CreateDocsUnoptimizedWay.cs


示例17: AddToInbox

 internal void AddToInbox(RevisionInternal rev)
 {
     Debug.Assert(IsRunning);
     Batcher.QueueObject(rev);
 }
开发者ID:woxihuanjia,项目名称:couchbase-lite-net,代码行数:5,代码来源:Replication.cs


示例18: TransformRevision

        internal RevisionInternal TransformRevision(RevisionInternal rev)
        {
            if (RevisionBodyTransformationFunction != null) {
                try {
                    var generation = rev.GetGeneration();
                    var xformed = RevisionBodyTransformationFunction(rev);
                    if (xformed == null) {
                        return null;
                    }

                    if (xformed != rev) {
                        Debug.Assert((xformed.GetDocId().Equals(rev.GetDocId())));
                        Debug.Assert((xformed.GetRevId().Equals(rev.GetRevId())));
                        Debug.Assert((xformed.GetProperties().Get("_revisions").Equals(rev.GetProperties().Get("_revisions"))));

                        if (xformed.GetProperties().ContainsKey("_attachments")) {
                            // Insert 'revpos' properties into any attachments added by the callback:
                            var mx = new RevisionInternal(xformed.GetProperties());
                            xformed = mx;
                            mx.MutateAttachments((name, info) =>
                            {
                                if (info.Get("revpos") != null) {
                                    return info;
                                }

                                if (info.Get("data") == null) {
                                    throw new InvalidOperationException("Transformer added attachment without adding data");
                                }

                                var newInfo = new Dictionary<string, object>(info);
                                newInfo["revpos"] = generation;
                                return newInfo;
                            });
                        }
                    }
                } catch (Exception e) {
                    Log.W(TAG, String.Format("Exception transforming a revision of doc '{0}'", rev.GetDocId()), e);
                }
            }

            return rev;
        }
开发者ID:woxihuanjia,项目名称:couchbase-lite-net,代码行数:42,代码来源:Replication.cs


示例19: RevsDiff

        public static ICouchbaseResponseState RevsDiff(ICouchbaseListenerContext context)
        {
            // Collect all of the input doc/revision IDs as CBL_Revisions:
            var revs = new RevisionList();
            var body = context.BodyAs<Dictionary<string, object>>();
            if (body == null) {
                return context.CreateResponse(StatusCode.BadJson).AsDefaultState();
            }

            foreach (var docPair in body) {
                var revIDs = docPair.Value.AsList<string>();
                if (revIDs == null) {
                    return context.CreateResponse(StatusCode.BadParam).AsDefaultState();
                }

                foreach (var revID in revIDs) {
                    var rev = new RevisionInternal(docPair.Key, revID.AsRevID(), false);
                    revs.Add(rev);
                }
            }

            return PerformLogicWithDatabase(context, true, db =>
            {
                var response = context.CreateResponse();
                // Look them up, removing the existing ones from revs:
                db.Storage.FindMissingRevisions(revs);

                // Return the missing revs in a somewhat different format:
                IDictionary<string, object> diffs = new Dictionary<string, object>();
                foreach(var rev in revs) {
                    var docId = rev.DocID;
                    IList<RevisionID> missingRevs = null;
                    if(!diffs.ContainsKey(docId)) {
                        missingRevs = new List<RevisionID>();
                        diffs[docId] = new Dictionary<string, IList<RevisionID>> { { "missing", missingRevs } };
                    } else {
                        missingRevs = ((Dictionary<string, IList<RevisionID>>)diffs[docId])["missing"];
                    }

                    missingRevs.Add(rev.RevID);
                }

                // Add the possible ancestors for each missing revision:
                foreach(var docPair in diffs) {
                    IDictionary<string, IList<RevisionID>> docInfo = (IDictionary<string, IList<RevisionID>>)docPair.Value;
                    int maxGen = 0;
                    RevisionID maxRevID = null;
                    foreach(var revId in docInfo["missing"]) {
                        if(revId.Generation > maxGen) {
                            maxGen = revId.Generation;
                            maxRevID = revId;
                        }
                    }

                    var rev = new RevisionInternal(docPair.Key, maxRevID, false);
                    var ancestors = db.Storage.GetPossibleAncestors(rev, 0, ValueTypePtr<bool>.NULL)?.ToList();
                    if(ancestors != null && ancestors.Count > 0) {
                        docInfo["possible_ancestors"] = ancestors;
                    }
                }

                response.JsonBody = new Body(diffs);
                return response;
            }).AsDefaultState();

        }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:66,代码来源:DatabaseMethods.cs


示例20: QueryView

        /// <summary>
        /// Queries the specified view using the specified options
        /// </summary>
        /// <returns>The HTTP response containing the results of the query</returns>
        /// <param name="context">The request context</param>
        /// <param name="db">The database to run the query in</param>
        /// <param name="view">The view to query</param>
        /// <param name="options">The options to apply to the query</param>
        public static CouchbaseLiteResponse QueryView(ICouchbaseListenerContext context, Database db, View view, QueryOptions options)
        {
            var result = view.QueryWithOptions(options);

            object updateSeq = options.UpdateSeq ? (object)view.LastSequenceIndexed : null;
            var mappedResult = new List<object>();
            foreach (var row in result) {
                row.Database = db;
                var dict = row.AsJSONDictionary();
                if (context.ContentOptions != DocumentContentOptions.None) {
                    var doc = dict.Get("doc").AsDictionary<string, object>();
                    if (doc != null) {
                        // Add content options:
                        RevisionInternal rev = new RevisionInternal(doc);
                        var status = new Status();
                        rev = DocumentMethods.ApplyOptions(context.ContentOptions, rev, context, db, status);
                        if (rev != null) {
                            dict["doc"] = rev.GetProperties();
                        }
                    }
                }

                mappedResult.Add(dict);
            }

            var body = new Body(new NonNullDictionary<string, object> {
                { "rows", mappedResult },
                { "total_rows", view.TotalRows },
                { "offset", options.Skip },
                { "update_seq", updateSeq }
            });

            var retVal = context.CreateResponse();
            retVal.JsonBody = body;
            return retVal;
        }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:44,代码来源:DatabaseMethods.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Tests.MockHttpClientFactory类代码示例发布时间:2022-05-24
下一篇:
C# Internal.Body类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap