當前位置: 首頁>>代碼示例>>C#>>正文


C# EventHandlerList.AddHandler方法代碼示例

本文整理匯總了C#中System.ComponentModel.EventHandlerList.AddHandler方法的典型用法代碼示例。如果您正苦於以下問題:C# EventHandlerList.AddHandler方法的具體用法?C# EventHandlerList.AddHandler怎麽用?C# EventHandlerList.AddHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ComponentModel.EventHandlerList的用法示例。


在下文中一共展示了EventHandlerList.AddHandler方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: All

		public void All ()
		{
			EventHandlerList list = new EventHandlerList ();
			string i1 = "i1";
			string i2 = "i2";
			EventHandler one = new EventHandler (Deleg1);
			EventHandler two = new EventHandler (Deleg2);
			EventHandler d;

			Assertion.AssertEquals ("All #01", null, list [i1]);
			Assertion.AssertEquals ("All #02", null, list [i2]);

			list.AddHandler (i1, one);
			d = list [i1] as EventHandler;
			Assertion.Assert ("All #03", d != null);

			d (this, EventArgs.Empty);
			Assertion.AssertEquals ("All #04", 1, calls);

			list.AddHandler (i2, two);
			d = list [i1] as EventHandler;
			Assertion.Assert ("All #05", d != null);

			d (this, EventArgs.Empty);
			Assertion.AssertEquals ("All #06", 2, calls);

			d = list [i2] as EventHandler;
			Assertion.Assert ("All #07", d != null);

			d (this, EventArgs.Empty);
			Assertion.AssertEquals ("All #08", 4, calls);

			list.AddHandler (i2, two);
			d = list [i2] as EventHandler;
			Assertion.Assert ("All #08", d != null);

			d (this, EventArgs.Empty);
			Assertion.AssertEquals ("All #09", 16, calls);

			list.RemoveHandler (i1, one);
			d = list [i1] as EventHandler;
			Assertion.Assert ("All #10", d == null);

			list.RemoveHandler (i2, two);
			d = list [i2] as EventHandler;
			Assertion.Assert ("All #11", d != null);

			list.RemoveHandler (i2, two);
			d = list [i2] as EventHandler;
			Assertion.Assert ("All #12", d == null);

			list.AddHandler (i1, one);
			d = list [i1] as EventHandler;
			Assertion.Assert ("All #13", d != null);

			list.AddHandler (i2, two);
			d = list [i2] as EventHandler;
			Assertion.Assert ("All #14", d != null);

			list.AddHandler (i1, null);
			Assertion.Assert ("All #15", list [i1] != null);

			list.AddHandler (i2, null);
			Assertion.Assert ("All #16", list [i2] != null);

			list.Dispose ();
		}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:67,代碼來源:EventHandlerListTests.cs

示例2: NullKey

		public void NullKey ()
		{
			EventHandlerList list = new EventHandlerList ();
			EventHandler one = new EventHandler (Deleg1);
			
			list.AddHandler (null, one);
			EventHandler d = list [null] as EventHandler;
			Assertion.Assert ("NullKey #01", d != null);
			
			list.RemoveHandler (null, one);
			d = list [null] as EventHandler;
			Assertion.Assert ("NullKey #02", d == null);
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:13,代碼來源:EventHandlerListTests.cs

示例3: All

		public void All ()
		{
			EventHandlerList list = new EventHandlerList ();
			string i1 = "i1";
			string i2 = "i2";
			EventHandler one = new EventHandler (Deleg1);
			EventHandler two = new EventHandler (Deleg2);
			EventHandler d;

			Assert.IsNull (list [i1], "All #01");
			Assert.IsNull (list [i2], "All #02");

			list.AddHandler (i1, one);
			d = list [i1] as EventHandler;
			Assert.IsNotNull (d, "All #03");

			d (this, EventArgs.Empty);
			Assert.AreEqual (1, calls, "All #04");

			list.AddHandler (i2, two);
			d = list [i1] as EventHandler;
			Assert.IsNotNull (d, "All #05");

			d (this, EventArgs.Empty);
			Assert.AreEqual (2, calls, "All #06");

			d = list [i2] as EventHandler;
			Assert.IsNotNull (d, "All #07");

			d (this, EventArgs.Empty);
			Assert.AreEqual (4, calls, "All #08");

			list.AddHandler (i2, two);
			d = list [i2] as EventHandler;
			Assert.IsNotNull (d, "All #08");

			d (this, EventArgs.Empty);
			Assert.AreEqual (16, calls, "All #09");

			list.RemoveHandler (i1, one);
			d = list [i1] as EventHandler;
			Assert.IsNull (d, "All #10");

			list.RemoveHandler (i2, two);
			d = list [i2] as EventHandler;
			Assert.IsNotNull (d, "All #11");

			list.RemoveHandler (i2, two);
			d = list [i2] as EventHandler;
			Assert.IsNull (d, "All #12");

			list.AddHandler (i1, one);
			d = list [i1] as EventHandler;
			Assert.IsNotNull (d, "All #13");

			list.AddHandler (i2, two);
			d = list [i2] as EventHandler;
			Assert.IsNotNull (d, "All #14");

			list.AddHandler (i1, null);
			Assert.IsNotNull (list [i1], "All #15");

			list.AddHandler (i2, null);
			Assert.IsNotNull (list [i2], "All #16");

			list.Dispose ();
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:67,代碼來源:EventHandlerListTests.cs

示例4: EventHandlerList

 public IHttpActionResult EventHandlerList()
 {
     EventHandlerList eventHandlers = new EventHandlerList();
     eventHandlers.AddHandler("StringProcessorDelegate", x);
     return Json(eventHandlers);
 }
開發者ID:wjkhappy14,項目名稱:aspnetwebstack,代碼行數:6,代碼來源:DelegateController.cs

示例5: NullKey

		public void NullKey ()
		{
			EventHandlerList list = new EventHandlerList ();
			EventHandler one = new EventHandler (Deleg1);
			
			list.AddHandler (null, one);
			EventHandler d = list [null] as EventHandler;
			Assert.IsNotNull (d, "NullKey #01");
			
			list.RemoveHandler (null, one);
			d = list [null] as EventHandler;
			Assert.IsNull (d, "NullKey #02");
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:13,代碼來源:EventHandlerListTests.cs


注:本文中的System.ComponentModel.EventHandlerList.AddHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。