本文整理汇总了C#中Couchbase.Lite.Database类的典型用法代码示例。如果您正苦于以下问题:C# Database类的具体用法?C# Database怎么用?C# Database使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Database类属于Couchbase.Lite命名空间,在下文中一共展示了Database类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: ValidationContextImpl
internal ValidationContextImpl(Database database, RevisionInternal currentRevision
, RevisionInternal newRev)
{
this.database = database;
this.currentRevision = currentRevision;
this.newRev = newRev;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例9: View
internal View(Database database, String name)
{
Database = database;
Name = name;
_id = -1;
// means 'unknown'
Collation = ViewCollation.Unicode;
}
示例10: ConversationDatabase
static ConversationDatabase()
{
conversations = new List<Conversation> ();
database = Manager.SharedInstance.GetDatabase ("conversations");
LoadConversations ();
}
示例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;
}
示例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;
}
示例13: Conversation
static Conversation()
{
database = Manager.SharedInstance.GetDatabase ("conversations");
defaultView = database.GetView ("conversation-messages");
defaultView.SetMap ((document, emit) => {
//
}, "1");
}
示例14: CreateDocumentsAsync
public static Task CreateDocumentsAsync(Database db, int n)
{
return db.RunAsync((database)=>
{
database.BeginTransaction();
ApiTest.CreateDocuments(database, n);
database.EndTransaction(true);
});
}
示例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;
}