IServiceLocator.TryGetService(T) 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 TryGetService<T>(out T service) - 2.
bool TryGetService<T>(string contract, out T service)
1. Overload¶
bool TryGetService<T>(out T service)
Summary: Attempts to retrieve a service object of the specified type from the service provider.
Type parameters
| Name | Description |
|---|---|
T | The type of service to retrieve. |
Parameters
| Name | Type | Description |
|---|---|---|
out service | T | When this method returns, contains the service object of type T if found; otherwise, the default value for the type. |
Returns: bool -- true if a service object of type T is found; otherwise, false.
2. Overload¶
bool TryGetService<T>(string contract, out T service)
Summary: Attempts to retrieve a service of the specified type and contract.
Type parameters
| Name | Description |
|---|---|
T | The type of service to retrieve. |
Parameters
| Name | Type | Description |
|---|---|---|
contract | string | The contract name that identifies the service. Cannot be null. |
out service | T | When this method returns, contains the requested service if found; otherwise, the default value for the type. |
Returns: bool -- true if the service was found and returned in the out parameter; otherwise, false.