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


C# ServiceContainer.Dispose方法代碼示例

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


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

示例1: RemoveService

		[Test] // RemoveService (Type, Boolean)
		public void RemoveService2_Disposed ()
		{
			ServiceContainer sc;
			ServiceContainer parent;

			ArrayList serviceInstance1 = new ArrayList ();
			ArrayList serviceInstance2 = new ArrayList ();

			Type serviceType1 = typeof (IList);
			Type serviceType2 = typeof (IEnumerable);

			parent = new ServiceContainer ();
			sc = new ServiceContainer (parent);
			sc.AddService (serviceType1, serviceInstance1, true);
			sc.AddService (serviceType2, serviceInstance2, false);

			sc.Dispose ();

			sc.RemoveService (serviceType1, false);
			sc.RemoveService (serviceType2, false);

			Assert.AreSame (serviceInstance1, sc.GetService (serviceType1), "#A1");
			Assert.IsNull (sc.GetService (serviceType2), "#A2");

			sc.RemoveService (serviceType1, true);
			sc.RemoveService (serviceType2, true);

			Assert.IsNull (sc.GetService (serviceType1), "#B1");
			Assert.IsNull (sc.GetService (serviceType2), "#B2");
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:31,代碼來源:ServiceContainerTest.cs

示例2: AddService

		[Test] // AddService (Type, ServiceCreatorCallback)
		public void AddService2_Disposed ()
		{
			object service;
			ServiceContainer sc;

			object callback = new ServiceCreatorCallback (
				Svc.ServiceCreator);

			sc = new ServiceContainer ();
			sc.AddService (typeof (Svc), callback);
			service = sc.GetService (typeof (Svc));
			Assert.IsNotNull (service, "#A");

			sc.Dispose ();

			service = sc.GetService (typeof (Svc));
			Assert.IsNull (service, "#B");

			sc.AddService (typeof (Svc), callback);
			service = sc.GetService (typeof (Svc));
			Assert.IsNotNull (service, "#C");
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:23,代碼來源:ServiceContainerTest.cs

示例3: AddService1_Disposed

		public void AddService1_Disposed ()
		{
			object service;
			ServiceContainer sc;

			object serviceInstance1 = new ArrayList ();
			object serviceInstance2 = new Hashtable ();

			sc = new ServiceContainer ();
			sc.AddService (typeof (ICollection), serviceInstance1);
			service = sc.GetService (typeof (ICollection));
			Assert.IsNotNull (service, "#A1");
			Assert.AreSame (serviceInstance1, service, "#A2");

			sc.Dispose ();

			service = sc.GetService (typeof (ICollection));
			Assert.IsNull (service, "#B");

			sc.AddService (typeof (ICollection), serviceInstance2);
			service = sc.GetService (typeof (ICollection));
			Assert.IsNotNull (service, "#C1");
			Assert.AreSame (serviceInstance2, service, "#C2");
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:24,代碼來源:ServiceContainerTest.cs


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