Open sandboxFocus

Class ServiceProvider<TBase>

An immutable implementation of IServiceProvider that will index services that implement the TBase interface. When a service is added to a ServiceProvider<TBase>, an mapping is created between the type of this object and the object itself, but also between the type of any interface derived from TBase and implemented by this object.

Inheritance
ServiceProvider<TBase>
Namespace: Metalama.Framework.Engine.Services
Assembly: Metalama.Framework.Sdk.dll
Syntax
public sealed class ServiceProvider<TBase> : ServiceProvider, IDisposable, IServiceProvider<TBase>, IServiceProvider where TBase : class
Type Parameters
Name Description
TBase

Properties

Name Description
Empty

Methods

Name Description
Dispose()
GetService(Type)

Gets the implementation of a given service type.

GetService<T>()
ToString()
WithService(TBase, bool)

Returns a new ServiceProvider<TBase> where a service have been added to the current ServiceProvider<TBase>. If the new service is already present in the current ServiceProvider<TBase>, it is replaced in the new ServiceProvider<TBase>.

WithServiceConditional<T>(Func<ServiceProvider<TBase>, T>)
WithService<T>(Func<ServiceProvider<TBase>, T>)
WithServices(IEnumerable<TBase>?)

Returns a new ServiceProvider<TBase> where some given services have been added to the current ServiceProvider<TBase>. If some of the new services are already present in the current ServiceProvider<TBase>, they are replaced in the new ServiceProvider<TBase>.

WithServices(TBase, params TBase[])

Returns a new ServiceProvider<TBase> where some given services have been added to the current ServiceProvider<TBase>. If some of the new services are already present in the current ServiceProvider<TBase>, they are replaced in the new ServiceProvider<TBase>.

WithUntypedService(Type, object, bool)

Extension Methods