Table of Contents

Class ControllerServices

Namespace
System.Web.Http.Controllers
Assembly
System.Web.Http.dll

Represents a container for services that can be specific to a controller. This shadows the services from its parent ServicesContainer. A controller can either set a service here, or fall through to the more global set of services.

public class ControllerServices : ServicesContainer, IDisposable
Inheritance
ControllerServices
Implements
Inherited Members

Constructors

ControllerServices(ServicesContainer)

Initializes a new instance of the ControllerServices class.

public ControllerServices(ServicesContainer parent)

Parameters

parent ServicesContainer

The parent services container.

Methods

ClearSingle(Type)

Removes a single-instance service from the default services.

protected override void ClearSingle(Type serviceType)

Parameters

serviceType Type

The type of service.

GetService(Type)

Gets a service of the specified type.

public override object GetService(Type serviceType)

Parameters

serviceType Type

The 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 Type

The service type.

Returns

List<object>

The list of service objects of the specified type.

GetServices(Type)

Gets the list of service objects for a given service type.

public override IEnumerable<object> GetServices(Type serviceType)

Parameters

serviceType Type

The 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 Type

The 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 Type

The service type.

service object

The service object that replaces the previous instance.