Open sandboxFocus

Struct GlobalServiceProvider

Provides access to globally scoped services. A wrapper around ServiceProvider<TBase> for IGlobalService.

Namespace: Metalama.Framework.Engine.Services
Assembly: Metalama.Framework.Sdk.dll
Syntax
public readonly struct GlobalServiceProvider
Remarks

Global services are singleton services that are shared across the entire Metalama process. Use GetService<T>() or GetRequiredService<T>() to retrieve services from this provider.

This type is immutable. Methods like WithService(IGlobalService) and WithServices(params IGlobalService[]) return a new instance instead of modifying the current one.

Properties

Name Description
IsNull

Gets a value indicating whether the current GlobalServiceProvider is null.

Underlying

Gets the underlying ServiceProvider<TBase> for IGlobalService.

Methods

Name Description
GetRequiredService<T>()

Gets a required service from the provider.

GetService<T>()

Gets an optional service from the provider.

ToString()
WithService(IGlobalService)

Returns a new GlobalServiceProvider with an additional service.

WithServices(params IGlobalService[])

Returns a new GlobalServiceProvider with additional services.

Operators

Name Description
implicit operator ServiceProvider<IGlobalService>(GlobalServiceProvider)

Implicitly converts a GlobalServiceProvider to a ServiceProvider<TBase>.

implicit operator GlobalServiceProvider(ServiceProvider<IGlobalService>)

Implicitly converts a ServiceProvider<TBase> to a GlobalServiceProvider.

See Also