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


C# Dictionary.PutAll方法代码示例

本文整理汇总了C#中Dictionary.PutAll方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.PutAll方法的具体用法?C# Dictionary.PutAll怎么用?C# Dictionary.PutAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dictionary的用法示例。


在下文中一共展示了Dictionary.PutAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InstallAttachmentBodies

		internal static IDictionary<string, object> InstallAttachmentBodies(IDictionary<string
			, object> attachments, Database database)
		{
			IDictionary<string, object> updatedAttachments = new Dictionary<string, object>();
			foreach (string name in attachments.Keys)
			{
				object value = attachments.Get(name);
				if (value is Couchbase.Lite.Attachment)
				{
					Couchbase.Lite.Attachment attachment = (Couchbase.Lite.Attachment)value;
					IDictionary<string, object> metadataMutable = new Dictionary<string, object>();
					metadataMutable.PutAll(attachment.GetMetadata());
					InputStream body = attachment.GetBodyIfNew();
					if (body != null)
					{
						// Copy attachment body into the database's blob store:
						BlobStoreWriter writer = BlobStoreWriterForBody(body, database);
						metadataMutable.Put("length", (long)writer.GetLength());
						metadataMutable.Put("digest", writer.MD5DigestString());
						metadataMutable.Put("follows", true);
						database.RememberAttachmentWriter(writer);
					}
					updatedAttachments.Put(name, metadataMutable);
				}
				else
				{
					if (value is AttachmentInternal)
					{
						throw new ArgumentException("AttachmentInternal objects not expected here.  Could indicate a bug"
							);
					}
					else
					{
						if (value != null)
						{
							updatedAttachments.Put(name, value);
						}
					}
				}
			}
			return updatedAttachments;
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:42,代码来源:Attachment.cs

示例2: SetDiagnostics

 private static void SetDiagnostics(SegmentInfo info, string source, IDictionary<string, string> details)
 {
     IDictionary<string, string> diagnostics = new Dictionary<string, string>();
     diagnostics["source"] = source;
     diagnostics["lucene.version"] = Constants.LUCENE_VERSION;
     diagnostics["os"] = Constants.OS_NAME;
     diagnostics["os.arch"] = Constants.OS_ARCH;
     diagnostics["os.version"] = Constants.OS_VERSION;
     diagnostics["java.version"] = Constants.JAVA_VERSION;
     diagnostics["java.vendor"] = Constants.JAVA_VENDOR;
     diagnostics["timestamp"] = Convert.ToString((DateTime.Now));
     if (details != null)
     {
         diagnostics.PutAll(details);
     }
     info.Diagnostics = diagnostics;
 }
开发者ID:joyanta,项目名称:lucene.net,代码行数:17,代码来源:IndexWriter.cs

示例3: GetChangesFeedParams

        internal IDictionary<string, object> GetChangesFeedParams()
        {
            if (docIDs != null && docIDs.Count > 0) {
                filterName = "_doc_ids";
                filterParams = new Dictionary<string, object>();
                filterParams.Put("doc_ids", docIDs);
            }

            var bodyParams = new Dictionary<string, object>();
            bodyParams["feed"] = GetFeed();
            bodyParams["heartbeat"] = _heartbeatMilliseconds;

            if (includeConflicts) {
                bodyParams["style"] = "all_docs";
            } else {
                bodyParams["style"] = null;
            }

            if (lastSequenceID != null) {
                Int64 sequenceAsLong;
                var success = Int64.TryParse(lastSequenceID.ToString(), out sequenceAsLong);
                bodyParams["since"] = success ? sequenceAsLong : lastSequenceID;
            }

            if (mode == ChangeTrackerMode.LongPoll) {
                bodyParams["limit"] = LongPollModeLimit;
            }

            if (filterName != null) {
                bodyParams["filter"] = filterName;
                bodyParams.PutAll(filterParams);
            }

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

示例4: SaveLastSequence

        private void SaveLastSequence(SaveLastSequenceCompletionBlock completionHandler)
        {
            
            if (!lastSequenceChanged) {
                if (completionHandler != null) {
                    completionHandler();
                }
                return;
            }

            if (_savingCheckpoint) {
                // If a save is already in progress, don't do anything. (The completion block will trigger
                // another save after the first one finishes.)
                Task.Delay(500).ContinueWith(t => SaveLastSequence(completionHandler));
            }

            lastSequenceChanged = false;

            Log.D(TAG, "saveLastSequence() called. lastSequence: " + LastSequence);

            var body = new Dictionary<String, Object>();
            if (_remoteCheckpoint != null) {
                body.PutAll(_remoteCheckpoint);
            }

            body["lastSequence"] = LastSequence;
            var remoteCheckpointDocID = RemoteCheckpointDocID();
            if (String.IsNullOrEmpty(remoteCheckpointDocID)) {
                Log.W(TAG, "remoteCheckpointDocID is null, aborting saveLastSequence()");
                return;
            }

            _savingCheckpoint = true;
            var message = SendAsyncRequest(HttpMethod.Put, "/_local/" + remoteCheckpointDocID, body, (result, e) => 
            {
                _savingCheckpoint = false;
                if (e != null) {
                    Log.V(TAG, "Unable to save remote checkpoint", e);
                }
                    
                

                if (e != null) {
                    switch (GetStatusFromError(e)) {
                        case StatusCode.NotFound:
                            _remoteCheckpoint = null;
                            break;
                        case StatusCode.Conflict:
                            RefreshRemoteCheckpointDoc();
                            break;
                        default:
                            // TODO: On 401 or 403, and this is a pull, remember that remote
                            // TODO: is read-only & don't attempt to read its checkpoint next time.
                            break;
                    }
                } else {
                    Log.D(TAG, "Save checkpoint response: " + result);
                    var response = result.AsDictionary<string, object>();
                    body.Put ("_rev", response.Get ("rev"));
                    _remoteCheckpoint = body;
                    var localDb = LocalDatabase;
                    if(localDb == null || localDb.Storage == null) {
                        Log.W(TAG, "Database is null, ignoring remote checkpoint response");
                        if(completionHandler != null) {
                            completionHandler();
                        }
                        return;
                    }
                    localDb.SetLastSequence(LastSequence, remoteCheckpointDocID);
                }

                if (completionHandler != null) {
                    completionHandler ();
                }
            });

            // This request should not be canceled when the replication is told to stop:
            Task dummy;
            _requests.TryRemove(message, out dummy);
        }
开发者ID:Steven-Mark-Ford,项目名称:couchbase-lite-net,代码行数:80,代码来源:Replication.cs

示例5: UpdateCheckedStatus

 /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
 public static void UpdateCheckedStatus(Couchbase.Lite.Document task, bool @checked
     )
 {
     IDictionary<string, object> properties = new Dictionary<string, object>();
     properties.PutAll(task.GetProperties());
     properties.Put("checked", @checked);
     task.PutProperties(properties);
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:9,代码来源:Task.cs

示例6: CopyWithDocID

 public virtual Couchbase.Lite.Internal.RevisionInternal CopyWithDocID(string docId
     , string revId)
 {
     //assert((docId != null) && (revId != null));
     System.Diagnostics.Debug.Assert((docId != null));
     System.Diagnostics.Debug.Assert(((this.docId == null) || (this.docId.Equals(docId
         ))));
     Couchbase.Lite.Internal.RevisionInternal result = new Couchbase.Lite.Internal.RevisionInternal
         (docId, revId, deleted, database);
     IDictionary<string, object> unmodifiableProperties = GetProperties();
     IDictionary<string, object> properties = new Dictionary<string, object>();
     if (unmodifiableProperties != null)
     {
         properties.PutAll(unmodifiableProperties);
     }
     properties.Put("_id", docId);
     properties.Put("_rev", revId);
     result.SetProperties(properties);
     return result;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:20,代码来源:RevisionInternal.cs

示例7: CopyWithDocID

        public RevisionInternal CopyWithDocID(String docId, String revId)
        {
            System.Diagnostics.Debug.Assert((docId != null));
            System.Diagnostics.Debug.Assert(((this.docId == null) || (this.docId.Equals(docId))));

            var result = new RevisionInternal(docId, revId, deleted, database);
            var unmodifiableProperties = GetProperties();
            var properties = new Dictionary<string, object>();
            if (unmodifiableProperties != null)
            {
                properties.PutAll(unmodifiableProperties);
            }
            properties["_id"] = docId;
            properties["_rev"] = revId;
            result.SetProperties(properties);
            return result;
        }
开发者ID:FireflyLogic,项目名称:couchbase-lite-net,代码行数:17,代码来源:RevisionInternal.cs

示例8: AddMemberToList

 /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
 public static void AddMemberToList(Couchbase.Lite.Document list, Couchbase.Lite.Document
      user)
 {
     IDictionary<string, object> newProperties = new Dictionary<string, object>();
     newProperties.PutAll(list.Properties);
     IList<string> members = (IList<string>)newProperties.Get("members");
     if (members == null)
     {
         members = new AList<string>();
     }
     members.AddItem(user.Id);
     newProperties.Put("members", members);
     try
     {
         list.PutProperties(newProperties);
     }
     catch (CouchbaseLiteException e)
     {
         Log.E(Application.Tag, "Cannot add member to the list", e);
     }
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:22,代码来源:List.cs

示例9: TestHistory

		//TODO issue: deleteLocalDocument should return error.code( see ios)
		// HISTORY
		/// <exception cref="System.Exception"></exception>
		public virtual void TestHistory()
		{
			IDictionary<string, object> properties = new Dictionary<string, object>();
			properties.Put("testName", "test06_History");
			properties.Put("tag", 1);
			Database db = StartDatabase();
			Document doc = CreateDocumentWithProperties(db, properties);
			string rev1ID = doc.GetCurrentRevisionId();
			Log.I(Tag, "1st revision: " + rev1ID);
			NUnit.Framework.Assert.IsNotNull("1st revision looks wrong: " + rev1ID, rev1ID.StartsWith
				("1-"));
			NUnit.Framework.Assert.AreEqual(doc.GetUserProperties(), properties);
			properties = new Dictionary<string, object>();
			properties.PutAll(doc.GetProperties());
			properties.Put("tag", 2);
			NUnit.Framework.Assert.IsNotNull(!properties.Equals(doc.GetProperties()));
			NUnit.Framework.Assert.IsNotNull(doc.PutProperties(properties));
			string rev2ID = doc.GetCurrentRevisionId();
			Log.I(Tag, "rev2ID" + rev2ID);
			NUnit.Framework.Assert.IsNotNull("2nd revision looks wrong:" + rev2ID, rev2ID.StartsWith
				("2-"));
			IList<SavedRevision> revisions = doc.GetRevisionHistory();
			Log.I(Tag, "Revisions = " + revisions);
			NUnit.Framework.Assert.AreEqual(revisions.Count, 2);
			SavedRevision rev1 = revisions[0];
			NUnit.Framework.Assert.AreEqual(rev1.GetId(), rev1ID);
			IDictionary<string, object> gotProperties = rev1.GetProperties();
			NUnit.Framework.Assert.AreEqual(1, gotProperties.Get("tag"));
			SavedRevision rev2 = revisions[1];
			NUnit.Framework.Assert.AreEqual(rev2.GetId(), rev2ID);
			NUnit.Framework.Assert.AreEqual(rev2, doc.GetCurrentRevision());
			gotProperties = rev2.GetProperties();
			NUnit.Framework.Assert.AreEqual(2, gotProperties.Get("tag"));
			IList<SavedRevision> tmp = new AList<SavedRevision>();
			tmp.AddItem(rev2);
			NUnit.Framework.Assert.AreEqual(doc.GetConflictingRevisions(), tmp);
			NUnit.Framework.Assert.AreEqual(doc.GetLeafRevisions(), tmp);
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:41,代码来源:ApiTest.cs

示例10: RemoveMemberFromList

 /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
 public static void RemoveMemberFromList(Couchbase.Lite.Document list, Couchbase.Lite.Document
      user)
 {
     IDictionary<string, object> newProperties = new Dictionary<string, object>();
     newProperties.PutAll(list.Properties);
     IList<string> members = (IList<string>)newProperties.Get("members");
     if (members != null)
     {
         members.Remove(user.Id);
     }
     newProperties.Put("members", members);
     list.PutProperties(newProperties);
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:14,代码来源:List.cs

示例11: AssignOwnerToListsIfNeeded

 /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
 public static void AssignOwnerToListsIfNeeded(Database database, Couchbase.Lite.Document
      user)
 {
     QueryEnumerator enumerator = GetQuery(database).Run();
     if (enumerator == null)
     {
         return;
     }
     foreach (var row in enumerator)
     {
         Couchbase.Lite.Document document = row.Document;
         string owner = (string)document.GetProperty("owner");
         if (owner != null)
         {
             continue;
         }
         IDictionary<string, object> properties = new Dictionary<string, object>();
         properties.PutAll(document.Properties);
         properties.Put("owner", user.Id);
         document.PutProperties(properties);
     }
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:23,代码来源:List.cs

示例12: SaveLastSequence

        internal void SaveLastSequence()
        {
            if (!lastSequenceChanged)
            {
                return;
            }
            if (savingCheckpoint)
            {
                // If a save is already in progress, don't do anything. (The completion block will trigger
                // another save after the first one finishes.)
                overdueForSave = true;
                return;
            }

            lastSequenceChanged = false;
            overdueForSave = false;

            Log.D(Tag, this + " saveLastSequence() called. lastSequence: " + LastSequence);

            var body = new Dictionary<String, Object>();
            if (remoteCheckpoint != null)
            {
                body.PutAll(remoteCheckpoint);
            }
            body["lastSequence"] = LastSequence;
            var remoteCheckpointDocID = RemoteCheckpointDocID();
            if (String.IsNullOrEmpty(remoteCheckpointDocID))
            {
                Log.W(Tag, this + ": remoteCheckpointDocID is null, aborting saveLastSequence()");
                return;
            }

            savingCheckpoint = true;
            Log.D(Tag, this + " put remote _local document.  checkpointID: " + remoteCheckpointDocID);
            SendAsyncRequest(HttpMethod.Put, "/_local/" + remoteCheckpointDocID, body, (result, e) => {
                savingCheckpoint = false;
                if (e != null) 
                {
                    Log.V (Tag, this + ": Unable to save remote checkpoint", e);
                }

                if (LocalDatabase == null)
                {
                    Log.W(Tag, this + ": Database is null, ignoring remote checkpoint response");
                    return;
                }

                if (e != null)
                {
                    switch (GetStatusFromError(e))
                    {
                        case StatusCode.NotFound:
                            {
                                remoteCheckpoint = null;
                                overdueForSave = true;
                                break;
                            }
                        case StatusCode.Conflict:
                            {
                                RefreshRemoteCheckpointDoc();
                                break;
                            }
                        default:
                            {
                                // TODO: On 401 or 403, and this is a pull, remember that remote
                                // TODO: is read-only & don't attempt to read its checkpoint next time.
                                break;
                            }
                    }
                }
                else 
                {
                    var response = (IDictionary<String, Object>)result;
                    body.Put ("_rev", response.Get ("rev"));
                    remoteCheckpoint = body;
                    LocalDatabase.SetLastSequence(LastSequence, RemoteCheckpointDocID(), IsPull);
                }

                if (overdueForSave) {
                    SaveLastSequence ();
                }
            });
        }
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:83,代码来源:Replication.cs

示例13: Copy

        public RevisionInternal Copy(string docId, RevisionID revId)
        {
            System.Diagnostics.Debug.Assert((docId != null));
            System.Diagnostics.Debug.Assert(((_docId == null) || (_docId.Equals(docId))));

            var result = new RevisionInternal(docId, revId, Deleted);
            var unmodifiableProperties = GetProperties();
            var properties = new Dictionary<string, object>();
            if(unmodifiableProperties != null) {
                properties.PutAll(unmodifiableProperties);
            }

            properties.SetDocRevID(docId, revId);
            result.SetProperties(properties);
            return result;
        }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:16,代码来源:RevisionInternal.cs

示例14: RevisionInternal

        internal RevisionInternal(RevisionInternal other) : this(other.DocID, other.RevID, other.Deleted)
        {
            var unmodifiableProperties = other.GetProperties();
            var properties = new Dictionary<string, object>();
            if(unmodifiableProperties != null) {
                properties.PutAll(unmodifiableProperties);
            }

            SetProperties(properties);
        }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:10,代码来源:RevisionInternal.cs

示例15: SetUserProperties

 public void SetUserProperties(IDictionary<string, object> userProperties)
 {
     IDictionary<string, object> newProps = new Dictionary<string, object>();
     newProps.PutAll(userProperties);
     foreach (string key in properties.Keys)
     {
         if (key.StartsWith("_"))
         {
             newProps.Put(key, properties.Get(key));
         }
     }
     // Preserve metadata properties
     properties = newProps;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:14,代码来源:UnsavedRevision.cs


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