Open sandboxFocus

Method GetRequiredService

GetRequiredService<T>(IServiceProvider<IGlobalService>)

Gets a required globally scoped service from the service provider, throwing an exception if the service is not available.

Declaration
public static T GetRequiredService<T>(this IServiceProvider<IGlobalService> serviceProvider) where T : class, IGlobalService
Parameters
Type Name Description
IServiceProvider<IGlobalService> serviceProvider

The service provider.

Returns
Type Description
T

The requested service.

Type Parameters
Name Description
T

The type of service to retrieve.

Exceptions
Type Condition
InvalidOperationException

The service is not available.

GetRequiredService<T>(IServiceProvider<IProjectService>)

Gets a required project-scoped service from the service provider, throwing an exception if the service is not available.

Declaration
public static T GetRequiredService<T>(this IServiceProvider<IProjectService> serviceProvider) where T : class, IProjectService
Parameters
Type Name Description
IServiceProvider<IProjectService> serviceProvider

The service provider.

Returns
Type Description
T

The requested service.

Type Parameters
Name Description
T

The type of service to retrieve.

Exceptions
Type Condition
InvalidOperationException

The service is not available.