System Center
Adds a new service to the container by instantiating the type T. The default lifetime will be singleton.
Namespace: Microsoft.EnterpriseManagement
Assembly: Microsoft.EnterpriseManagement.Core (in microsoft.enterprisemanagement.core.dll)
Usage
'Usage
Dim instance As Container
Dim name As String
Dim instance As V
instance.AddService(name, instance)
Syntax
'Declaration
Public Sub AddService(Of T, V As T) ( _
name As String, _
instance As V _
)
public void AddService<T,V> (
string name,
V instance
) where V : T
public:
generic<typename T, typename V> where V : T
virtual void AddService (
String^ name,
V instance
) sealed
GenericParameters
- T
The type of the service to instantiate.
- V
The type of object to create.
Parameters
- name
The name that the service will be stored as.
- instance
The instance to store.
Exceptions
Exception type | Condition |
---|---|
ArgumentNullException | The name parameter is a null reference (Nothing in Visual Basic) or empty. |
ArgumentNullException | The context parameter is a null reference (Nothing in Visual Basic) or empty. |
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Development Platforms
Windows Vista, Windows Server 2003, and
Target Platforms
Windows Server 2008,Windows Server 2003
See Also
Reference
Container Class
Container Members
Microsoft.EnterpriseManagement Namespace