Class SingleServiceProvider
A service provider that provides a single service.
public class SingleServiceProvider : IServiceProvider
- Inheritance
-
SingleServiceProvider
- Implements
- Derived
- Inherited Members
- Extension Methods
Remarks
Note that the service type must match exactly; added service types that are base types of the requested service type will not be matched.
Constructors
SingleServiceProvider(Type, object)
Initializes a new instance of the SingleServiceProvider class.
public SingleServiceProvider(Type serviceType, object serviceInstance)
Parameters
Remarks
Note that the service type must match exactly; added service types that are base types of the requested service type will not be matched.
Exceptions
- ArgumentNullException
serviceTypeis null.- ArgumentNullException
serviceInstanceis null.
Methods
GetService(Type)
Gets the service object of the specified type.
public object GetService(Type serviceType)
Parameters
serviceTypeTypeAn object that specifies the type of service object to get.
Returns
- object
A service object of type
serviceType, or null if there is no service object of typeserviceType.
Remarks
Note that the service type must match exactly; added service types that are base types of the requested service type will not be matched.