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


C# Dictionary.Put方法代码示例

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


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

示例1: Run

 public bool Run()
 {
     StringBuilder sb = new StringBuilder();
     for (int i = 0; i < this._enclosing.GetSizeOfAttachment(); i++)
     {
         sb.Append('1');
     }
     byte[] attach1 = Sharpen.Runtime.GetBytesForString(sb.ToString());
     try
     {
         Status status = new Status();
         for (int i_1 = 0; i_1 < this._enclosing.GetNumberOfDocuments(); i_1++)
         {
             IDictionary<string, object> rev1Properties = new Dictionary<string, object>();
             rev1Properties.Put("foo", 1);
             rev1Properties.Put("bar", false);
             RevisionInternal rev1 = this._enclosing.database.PutRevision(new RevisionInternal
                 (rev1Properties, this._enclosing.database), null, false, status);
             NUnit.Framework.Assert.AreEqual(Status.Created, status.GetCode());
             this._enclosing.database.InsertAttachmentForSequenceWithNameAndType(new ByteArrayInputStream
                 (attach1), rev1.GetSequence(), Test3_CreateDocsWithAttachments._testAttachmentName
                 , "text/plain", rev1.GetGeneration());
             NUnit.Framework.Assert.AreEqual(Status.Created, status.GetCode());
         }
     }
     catch (Exception t)
     {
         Log.E(Test3_CreateDocsWithAttachments.Tag, "Document create with attachment failed"
             , t);
         return false;
     }
     return true;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:33,代码来源:Test3_CreateDocsWithAttachments.cs

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

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

示例4: TestMultiValPath

        public void TestMultiValPath()
        {
            IndexReader reader = IndexReader.Open(directory, true);
            BoboIndexReader boboReader = BoboIndexReader.GetInstance(reader, facetHandlers);

            BoboBrowser browser = new BoboBrowser(boboReader);
            BrowseRequest req = new BrowseRequest();

            BrowseSelection sel = new BrowseSelection(PathHandlerName);
            sel.AddValue("/a");
            var propMap = new Dictionary<String, String>();
            propMap.Put(PathFacetHandler.SEL_PROP_NAME_DEPTH, "0");
            propMap.Put(PathFacetHandler.SEL_PROP_NAME_STRICT, "false");
            sel.SetSelectionProperties(propMap);

            req.AddSelection(sel);

            FacetSpec fs = new FacetSpec();
            fs.MinHitCount = (1);
            req.SetFacetSpec(PathHandlerName, fs);

            BrowseResult res = browser.Browse(req);
            Assert.AreEqual(res.NumHits, 1);
            IFacetAccessible fa = res.GetFacetAccessor(PathHandlerName);
            IEnumerable<BrowseFacet> facets = fa.GetFacets();
            Console.WriteLine(facets);
            Assert.AreEqual(1, facets.Count());
            BrowseFacet facet = facets.Get(0);
            Assert.AreEqual(2, facet.FacetValueHitCount);
        }
开发者ID:modulexcite,项目名称:BoboBrowse.Net,代码行数:30,代码来源:PathMultiValTest.cs

示例5: TestDatabase

 public virtual void TestDatabase()
 {
     Send("PUT", "/database", Status.Created, null);
     IDictionary entries = new Dictionary<string, IDictionary<string, object>>();
     entries.Put("results", new AList<object>());
     entries.Put("last_seq", 0);
     Send("GET", "/database/_changes?feed=normal&heartbeat=300000&style=all_docs", Status
         .Ok, entries);
     IDictionary<string, object> dbInfo = (IDictionary<string, object>)Send("GET", "/database"
         , Status.Ok, null);
     NUnit.Framework.Assert.AreEqual(6, dbInfo.Count);
     NUnit.Framework.Assert.AreEqual(0, dbInfo.Get("doc_count"));
     NUnit.Framework.Assert.AreEqual(0, dbInfo.Get("update_seq"));
     NUnit.Framework.Assert.IsTrue((int)dbInfo.Get("disk_size") > 8000);
     NUnit.Framework.Assert.AreEqual("database", dbInfo.Get("db_name"));
     NUnit.Framework.Assert.IsTrue(Runtime.CurrentTimeMillis() * 1000 > (long)dbInfo.Get
         ("instance_start_time"));
     NUnit.Framework.Assert.IsTrue(dbInfo.ContainsKey("db_uuid"));
     Send("PUT", "/database", Status.PreconditionFailed, null);
     Send("PUT", "/database2", Status.Created, null);
     IList<string> allDbs = new AList<string>();
     allDbs.AddItem("cblite-test");
     allDbs.AddItem("database");
     allDbs.AddItem("database2");
     Send("GET", "/_all_dbs", Status.Ok, allDbs);
     dbInfo = (IDictionary<string, object>)Send("GET", "/database2", Status.Ok, null);
     NUnit.Framework.Assert.AreEqual("database2", dbInfo.Get("db_name"));
     Send("DELETE", "/database2", Status.Ok, null);
     allDbs.Remove("database2");
     Send("GET", "/_all_dbs", Status.Ok, allDbs);
     Send("PUT", "/database%2Fwith%2Fslashes", Status.Created, null);
     dbInfo = (IDictionary<string, object>)Send("GET", "/database%2Fwith%2Fslashes", Status
         .Ok, null);
     NUnit.Framework.Assert.AreEqual("database/with/slashes", dbInfo.Get("db_name"));
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:35,代码来源:RouterTest.cs

示例6: TestNewDocumentHasCurrentRevision

 /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
 public virtual void TestNewDocumentHasCurrentRevision()
 {
     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.GetCurrentRevisionId());
     NUnit.Framework.Assert.IsNotNull(document.GetCurrentRevision());
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:11,代码来源:DocumentTest.cs

示例7: 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:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:13,代码来源:RevTreeTest.cs

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

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

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

示例11: Run

 public bool Run()
 {
     string[] bigObj = new string[this._enclosing.GetSizeOfDocument()];
     for (int i = 0; i < this._enclosing.GetSizeOfDocument(); i++)
     {
         bigObj[i] = Test11_DeleteDocs._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);
         Document doc = this._enclosing.database.CreateDocument();
         this._enclosing.docs[i_1] = doc;
         try
         {
             doc.PutProperties(props);
         }
         catch (CouchbaseLiteException cblex)
         {
             Log.E(Test11_DeleteDocs.Tag, "Document creation failed", cblex);
             return false;
         }
     }
     return true;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:26,代码来源:Test11_DeleteDocs.cs

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

示例13: TestParseContentType

		public virtual void TestParseContentType()
		{
			Encoding utf8 = Sharpen.Extensions.GetEncoding("UTF-8");
			Dictionary<string, byte[]> contentTypes = new Dictionary<string, byte[]>();
			contentTypes.Put("multipart/related; boundary=\"BOUNDARY\"", Sharpen.Runtime.GetBytesForString
				(new string("\r\n--BOUNDARY"), utf8));
			contentTypes.Put("multipart/related; boundary=BOUNDARY", Sharpen.Runtime.GetBytesForString
				(new string("\r\n--BOUNDARY"), utf8));
			contentTypes.Put("multipart/related;boundary=X", Sharpen.Runtime.GetBytesForString
				(new string("\r\n--X"), utf8));
			foreach (string contentType in contentTypes.Keys)
			{
				MultipartReaderDelegate delegate_ = null;
				MultipartReader reader = new MultipartReader(contentType, delegate_);
				byte[] expectedBoundary = (byte[])contentTypes.Get(contentType);
				byte[] boundary = reader.GetBoundary();
				NUnit.Framework.Assert.IsTrue(Arrays.Equals(boundary, expectedBoundary));
			}
			try
			{
				MultipartReaderDelegate delegate_ = null;
				MultipartReader reader = new MultipartReader("multipart/related; boundary=\"BOUNDARY"
					, delegate_);
				NUnit.Framework.Assert.IsTrue("Should not have gotten here, above lines should have thrown exception"
					, false);
			}
			catch (Exception)
			{
			}
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:30,代码来源:MultipartReaderTest.cs

示例14: CreatePersonaAuthenticator

 public static Authenticator CreatePersonaAuthenticator(string assertion, string email
     )
 {
     // TODO: REVIEW : Do we need email?
     IDictionary<string, string> @params = new Dictionary<string, string>();
     @params.Put("access_token", assertion);
     return new TokenAuthenticator("_persona", @params);
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:8,代码来源:AuthenticatorFactory.cs

示例15: ScriptableOutputStream

		/// <summary>ScriptableOutputStream constructor.</summary>
		/// <remarks>
		/// ScriptableOutputStream constructor.
		/// Creates a ScriptableOutputStream for use in serializing
		/// JavaScript objects. Calls excludeStandardObjectNames.
		/// </remarks>
		/// <param name="out">the OutputStream to write to.</param>
		/// <param name="scope">the scope containing the object.</param>
		/// <exception cref="System.IO.IOException"></exception>
		public ScriptableOutputStream(Stream @out, Scriptable scope) : base(@out)
		{
			// API class
			this.scope = scope;
			table = new Dictionary<object, string>();
			table.Put(scope, string.Empty);
			EnableReplaceObject(true);
			ExcludeStandardObjectNames();
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:18,代码来源:ScriptableOutputStream.cs


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