Table of Contents

Class ExtensibleFactory<TService, TSettingsBase>

Namespace
Silverback.ExtensibleFactories
Assembly
Silverback.Core.dll

The base class for factories used to allow extension in additional packages, for example adding other storage types.

public abstract class ExtensibleFactory<TService, TSettingsBase> where TService : notnull where TSettingsBase : IEquatable<TSettingsBase>

Type Parameters

TService

The type of the service to build.

TSettingsBase

The base type of the settings to use.

Inheritance
ExtensibleFactory<TService, TSettingsBase>
Derived
Inherited Members

Remarks

Two versions are available:

Constructors

ExtensibleFactory()

protected ExtensibleFactory()

Methods

AddFactory<TSettings>(Func<TSettings, IServiceProvider, TService>)

Registers the factory for the specified settings type.

public virtual void AddFactory<TSettings>(Func<TSettings, IServiceProvider, TService> factory) where TSettings : TSettingsBase

Parameters

factory Func<TSettings, IServiceProvider, TService>

The factory building the TService according to the specified settings.

Type Parameters

TSettings

The type of the settings.

GetService<TSettings>(TSettings, IServiceProvider)

Returns an object of type TService according to the specified settings.

protected TService GetService<TSettings>(TSettings settings, IServiceProvider serviceProvider) where TSettings : TSettingsBase

Parameters

settings TSettings

The settings that will be used to create the service.

serviceProvider IServiceProvider

The IServiceProvider that can be used to resolve additional services.

Returns

TService

The service of type TService, or null if no factory is registered for the specified settings type.

Type Parameters

TSettings

The type of the settings.

HasFactory<TSettings>()

Returns a boolean value indicating whether a factory for the specified settings type is registered.

public bool HasFactory<TSettings>()

Returns

bool

A value indicating whether a factory for the specified settings type is registered.

Type Parameters

TSettings

The type of the settings.

OverrideFactories(Func<TSettingsBase, IServiceProvider, TService>)

Overrides all registered factories with the specified factory.

public void OverrideFactories(Func<TSettingsBase, IServiceProvider, TService> factory)

Parameters

factory Func<TSettingsBase, IServiceProvider, TService>

The factory to be used regardless of the settings type.