Class DefaultServices
Represents a container for service instances used by the HttpConfiguration. Note that this container only supports known types, and methods to get or set arbitrary service types will throw ArgumentException when called. For creation of arbitrary types, please use IDependencyResolver instead. The supported types for this container are: IActionValueBinderIApiExplorerIAssembliesResolverIBodyModelValidatorSystem.Net.Http.Formatting.IContentNegotiatorIDocumentationProviderIFilterProviderIHostBufferPolicySelectorIHttpActionInvokerIHttpActionSelectorIHttpControllerActivatorIHttpControllerSelectorIHttpControllerTypeResolverITraceManagerITraceWriterSystem.Web.Http.Query.IStructuredQueryBuilderModelBinderProviderModelMetadataProviderModelValidatorProviderValueProviderFactoryPassing any type which is not on this to any method on this interface will cause an ArgumentException to be thrown.
public class DefaultServices : ServicesContainer, IDisposable
- Inheritance
-
DefaultServices
- Implements
- Inherited Members
Constructors
DefaultServices()
Initializes a new instance of the DefaultServices class.
protected DefaultServices()
DefaultServices(HttpConfiguration)
Initializes a new instance of the DefaultServices class with a specified HttpConfiguration object.
public DefaultServices(HttpConfiguration configuration)
Parameters
configuration
HttpConfigurationThe HttpConfiguration object.
Methods
ClearSingle(Type)
Removes a single-instance service from the default services.
protected override void ClearSingle(Type serviceType)
Parameters
serviceType
TypeThe type of the service.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public override void Dispose()
GetService(Type)
Gets a service of the specified type.
public override object GetService(Type serviceType)
Parameters
serviceType
TypeThe type of service.
Returns
- object
The first instance of the service, or null if the service is not found.
GetServiceInstances(Type)
Gets the list of service objects for a given service type, and validates the service type.
protected override List<object> GetServiceInstances(Type serviceType)
Parameters
serviceType
TypeThe service type.
Returns
GetServices(Type)
Gets the list of service objects for a given service type.
public override IEnumerable<object> GetServices(Type serviceType)
Parameters
serviceType
TypeThe type of service.
Returns
- IEnumerable<object>
The list of service objects of the specified type, or an empty list if the service is not found.
IsSingleService(Type)
Queries whether a service type is single-instance.
public override bool IsSingleService(Type serviceType)
Parameters
serviceType
TypeThe service type.
Returns
- bool
true if the service type has at most one instance, or false if the service type supports multiple instances.
ReplaceSingle(Type, object)
Replaces a single-instance service object.
protected override void ReplaceSingle(Type serviceType, object service)
Parameters
serviceType
TypeThe service type.
service
objectThe service object that replaces the previous instance.
ResetCache(Type)
Removes the cached values for a single service type.
protected override void ResetCache(Type serviceType)
Parameters
serviceType
TypeThe service type.