ServiceContainer.RemoveService 方法

定義

從服務容器中移除特定服務型別。Removes the specified service type from the service container.

多載

RemoveService(Type)

從服務容器中移除特定服務型別。Removes the specified service type from the service container.

RemoveService(Type, Boolean)

從服務容器中移除特定服務型別。Removes the specified service type from the service container.

RemoveService(Type)

從服務容器中移除特定服務型別。Removes the specified service type from the service container.

public:
 virtual void RemoveService(Type ^ serviceType);
public void RemoveService (Type serviceType);
abstract member RemoveService : Type -> unit
override this.RemoveService : Type -> unit
Public Sub RemoveService (serviceType As Type)

參數

serviceType
Type

要移除的服務型別。The type of service to remove.

實作

例外狀況

serviceTypenullserviceType is null.

範例

下列範例說明如何從ServiceContainer移除服務。The following example illustrates how to remove a service from a ServiceContainer.

m_MyServiceContainer->RemoveService( Control::typeid );
m_MyServiceContainer.RemoveService(typeof(Control));
m_MyServiceContainer.RemoveService(GetType(Control))

另請參閱

RemoveService(Type, Boolean)

從服務容器中移除特定服務型別。Removes the specified service type from the service container.

public:
 virtual void RemoveService(Type ^ serviceType, bool promote);
public void RemoveService (Type serviceType, bool promote);
abstract member RemoveService : Type * bool -> unit
override this.RemoveService : Type * bool -> unit
Public Sub RemoveService (serviceType As Type, promote As Boolean)

參數

serviceType
Type

要移除的服務型別。The type of service to remove.

promote
Boolean

如果這個服務應該從任何父服務容器移除,則為 true,否則為 falsetrue if this service should be removed from any parent service containers; otherwise, false.

實作

例外狀況

serviceTypenullserviceType is null.

另請參閱

適用於