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

C# Lite.Database类代码示例

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

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



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

 public static Query GetQuery(Database database, string listDocId)
 {
     View view = database.GetView(ViewName);
     if (view.Map == null)
     {
         view.Map += (IDictionary<string, object> document, EmitDelegate emitter)=> 
         {
             if (Task.DocType.Equals(document.Get("type")))
             {
                 var keys = new AList<object>();
                 keys.AddItem(document.Get("list_id"));
                 keys.AddItem(document.Get("created_at"));
                 emitter(keys, document);
             }
         };
     }
     Query query = view.CreateQuery();
     query.Descending = true;
     IList<object> startKeys = new AList<object>();
     startKeys.AddItem(listDocId);
     startKeys.AddItem(new Dictionary<string, object>());
     IList<object> endKeys = new AList<object>();
     endKeys.AddItem(listDocId);
     query.StartKey = startKeys;
     query.EndKey = endKeys;
     return query;
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:27,代码来源:Task.cs


示例3: 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


示例4: CreateTask

 /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
 public static Couchbase.Lite.Document CreateTask(Database database, string title, 
     Bitmap image, string listId)
 {
     SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
         );
     Calendar calendar = GregorianCalendar.GetInstance();
     string currentTimeString = dateFormatter.Format(calendar.GetTime());
     IDictionary<string, object> properties = new Dictionary<string, object>();
     properties.Put("type", DocType);
     properties.Put("title", title);
     properties.Put("checked", false);
     properties.Put("created_at", currentTimeString);
     properties.Put("list_id", listId);
     Couchbase.Lite.Document document = database.CreateDocument();
     UnsavedRevision revision = document.CreateRevision();
     revision.SetUserProperties(properties);
     if (image != null)
     {
         ByteArrayOutputStream @out = new ByteArrayOutputStream();
         image.Compress(Bitmap.CompressFormat.Jpeg, 50, @out);
         ByteArrayInputStream @in = new ByteArrayInputStream(@out.ToByteArray());
         revision.SetAttachment("image", "image/jpg", @in);
     }
     revision.Save();
     return document;
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:27,代码来源:Task.cs


示例5: Pusher

		/// <summary>Constructor</summary>
        public Pusher(Database db, Uri remote, bool continuous, IHttpClientFactory clientFactory
            , TaskFactory workExecutor) : base(db, remote, continuous, clientFactory
			, workExecutor)
		{
			CreateTarget = false;
			observing = false;
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:8,代码来源:Pusher.cs


示例6: CreateDocumentWithProperties

        public static Document CreateDocumentWithProperties(Database db, IDictionary<String, Object> properties)
		{
            var doc = db.CreateDocument();

			Assert.IsNotNull(doc);
			Assert.IsNull(doc.CurrentRevisionId);
			Assert.IsNull(doc.CurrentRevision);
			Assert.IsNotNull("Document has no ID", doc.Id);

			// 'untitled' docs are no longer untitled (8/10/12)
			try
			{
				doc.PutProperties(properties);
			}
			catch (Exception e)
			{
				Log.E(Tag, "Error creating document", e);
                Assert.IsTrue( false, "can't create new document in db:" + db.Name +
                    " with properties:" + properties.Aggregate(new StringBuilder(" >>> "), (str, kvp)=> { str.AppendFormat("'{0}:{1}' ", kvp.Key, kvp.Value); return str; }, str=>str.ToString()));
			}

			Assert.IsNotNull(doc.Id);
			Assert.IsNotNull(doc.CurrentRevisionId);
			Assert.IsNotNull(doc.UserProperties);
			Assert.AreEqual(db.GetDocument(doc.Id), doc);

			return doc;
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:28,代码来源:ApiTest.cs


示例7: 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


示例8: DeserializeObject

        /// <summary>
        /// Deserializes a <c>Document</c>
        /// </summary>
        /// <returns>A new object deserialized.</returns>
        /// <param name="db">The <c>Database</c> where the Document is stored.</param>
        /// <param name="doc">The document to deserialize.</param>
        /// <param name = "serializer">The serializer to use when deserializing the object</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        internal static object DeserializeObject(Type type, Document doc, Database db,
		                                          IDReferenceResolver resolver = null)
        {
            JObject jo = JObject.FromObject (doc.Properties);
            JsonSerializer serializer = GetSerializer (type, doc.CurrentRevision, db,
                                            resolver, GetLocalTypes (type));
            return jo.ToObject (type, serializer);
        }
开发者ID:GNOME,项目名称:longomatch,代码行数:16,代码来源:DocumentsSerializer.cs


示例9: View

 internal View(Database database, String name)
 {
     Database = database;
     Name = name;
     _id = -1;
     // means 'unknown'
     Collation = ViewCollation.Unicode;
 }
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:8,代码来源:View.cs


示例10: ConversationDatabase

        static ConversationDatabase()
        {
            conversations = new List<Conversation> ();

            database = Manager.SharedInstance.GetDatabase ("conversations");

            LoadConversations ();
        }
开发者ID:CAMongrel,项目名称:OpenFlow,代码行数:8,代码来源:ConversationDatabase.cs


示例11: RevisionInternal

 public RevisionInternal(String docId, String revId, Boolean deleted, Database database)
 {
     // TODO: get rid of this field!
     this.docId = docId;
     this.revId = revId;
     this.deleted = deleted;
     this.database = database;
 }
开发者ID:FireflyLogic,项目名称:couchbase-lite-net,代码行数:8,代码来源:RevisionInternal.cs


示例12: RemoteMultipartRequest

 public RemoteMultipartRequest(ScheduledExecutorService workExecutor, HttpClientFactory
      clientFactory, string method, Uri url, MultipartEntity multiPart, Database db, 
     IDictionary<string, object> requestHeaders, RemoteRequestCompletionBlock onCompletion
     ) : base(workExecutor, clientFactory, method, url, null, db, requestHeaders, onCompletion
     )
 {
     this.multiPart = multiPart;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:8,代码来源:RemoteMultipartRequest.cs


示例13: Conversation

 static Conversation()
 {
     database = Manager.SharedInstance.GetDatabase ("conversations");
     defaultView = database.GetView ("conversation-messages");
     defaultView.SetMap ((document, emit) => {
         //
     }, "1");
 }
开发者ID:CAMongrel,项目名称:OpenFlow,代码行数:8,代码来源:Conversation.cs


示例14: CreateDocumentsAsync

        public static Task CreateDocumentsAsync(Database db, int n)
		{
            return db.RunAsync((database)=>
                {
                    database.BeginTransaction();
                    ApiTest.CreateDocuments(database, n);
                    database.EndTransaction(true);
                });
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:9,代码来源:ApiTest.cs


示例15: Query

 internal Query(Database database, View view)
 {
     // null for _all_docs query
     Database = database;
     View = view;
     Limit = Int32.MaxValue;
     MapOnly = (view != null && view.Reduce == null);
     IndexUpdateMode = IndexUpdateMode.Before;
     AllDocsMode = AllDocsMode.AllDocs;
 }
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:10,代码来源:Query.cs


示例16: GetQuery

 public static Query GetQuery(Database database, string ignoreUserId)
 {
     View view = database.GetView(ViewName);
     if (view.GetMap() == null)
     {
         Mapper map = new _Mapper_30(ignoreUserId);
         view.SetMap(map, null);
     }
     Query query = view.CreateQuery();
     return query;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:11,代码来源:Profile.cs


示例17: CreateDocuments

  		public static void CreateDocuments(Database db, int numberOfDocsToCreate)
		{
			//TODO should be changed to use db.runInTransaction
			for (int i = 0; i < numberOfDocsToCreate; i++)
			{
                var properties = new Dictionary<String, Object>();
                properties["testName"] = "testDatabase";
                properties["sequence"] = i;
				CreateDocumentWithProperties(db, properties);
			}
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:11,代码来源:ApiTest.cs


示例18: GetQueryById

 public static Query GetQueryById(Database database, string userId)
 {
     View view = database.GetView(ByIdViewName);
     if (view.GetMap() == null)
     {
         Mapper map = new _Mapper_52();
         view.SetMap(map, null);
     }
     Query query = view.CreateQuery();
     IList<object> keys = new AList<object>();
     keys.AddItem(userId);
     query.SetKeys(keys);
     return query;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:14,代码来源:Profile.cs


示例19: CreateNewList

 /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
 public static Couchbase.Lite.Document CreateNewList(Database database, string title, string userId)
 {
     var dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
     var calendar = Calendar.CurrentEra;
     string currentTimeString = dateFormatter.Format(calendar.GetTime());
     IDictionary<string, object> properties = new Dictionary<string, object>();
     properties.Put("type", "list");
     properties.Put("title", title);
     properties.Put("created_at", currentTimeString);
     properties.Put("owner", "profile:" + userId);
     properties.Put("members", new AList<string>());
     Couchbase.Lite.Document document = database.CreateDocument();
     document.PutProperties(properties);
     return document;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:16,代码来源:List.cs


示例20: ReadToDatabase

        public static IDictionary<string, object> ReadToDatabase(IEnumerable<byte> data, IDictionary<string, string> headers, 
            Database db)
        {
            var realized = data.ToArray();
            if (realized.Length == 0) {
                throw new CouchbaseLiteException(StatusCode.BadJson);
            }

            var reader = new MultipartDocumentReader(db);
            reader.SetHeaders(headers);
            reader.AppendData(data);
            reader.Finish();

            return reader.document;
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:15,代码来源:MultipartDocumentReader.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Lite.Replication类代码示例发布时间:2022-05-24
下一篇:
C# Lite.BlobKey类代码示例发布时间: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