IServiceLocator.TryGetService(T) method¶
Defined in
Type: IServiceLocator
Namespace: Splat
Assembly: Splat.Core.dll
Applies to
net10.0, net9.0, net8.0, net462, net481
Overloads¶
-
bool TryGetService<T>(out T service) -
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.