Skip to content

IServiceLocator.HasService() method

Defined in

Type: IServiceLocator Namespace: Splat Assembly: Splat.Core.dll

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481, net471

Overloads

  • 1. bool HasService<T>()
  • 2. bool HasService<T>(string contract)

1. Overload

bool HasService<T>()

Summary: Determines whether a service of the specified type is available from the service provider.

Type parameters

NameDescription
TThe type of service to check for availability.

Returns: bool -- true if a service of type T is available; otherwise, false.

2. Overload

bool HasService<T>(string contract)

Summary: Determines whether a service of the specified type and contract is available from the service provider.

Type parameters

NameDescription
TThe type of the service to check for.

Parameters

NameTypeDescription
contractstringThe contract name that identifies the service. Cannot be null.

Returns: bool -- true if a service of type T with the specified contract is available; otherwise, false.