本文整理汇总了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");
}
示例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");
}
示例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");
}