Skip to content

Dependency Struct

Represents a dependency that can be overridden in a service provider. This struct provides various static methods to create dependency overrides based on type, instance, or factory functions.

C#
public readonly struct Dependency

Methods

Dependency.Override(Type, object) Method

Creates a dependency override with a specific instance for the declared type.

C#
public static Abblix.DependencyInjection.Dependency Override(System.Type declared, object instance);

Parameters

declared System.Type

The declared type of the dependency.

instance System.Object

The instance to use for the dependency.

Returns

Dependency
A new Dependency instance.

Dependency.Override(Type, Func<IServiceProvider,object>) Method

Creates a dependency override using a factory function for the declared type.

C#
public static Abblix.DependencyInjection.Dependency Override(System.Type declared, System.Func<System.IServiceProvider,object> factory);

Parameters

declared System.Type

The declared type of the dependency.

factory System.Func<System.IServiceProvider,System.Object>

The factory function to create the dependency instance.

Returns

Dependency
A new Dependency instance.

Dependency.Override(Type, Type) Method

Creates a dependency override where a specified actual type fulfills the contract of a declared type.

C#
public static Abblix.DependencyInjection.Dependency Override(System.Type declared, System.Type actual);

Parameters

declared System.Type

The declared type of the dependency.

actual System.Type

The actual type to be used as the implementation.

Returns

Dependency
A new Dependency instance.

Dependency.Override<TDeclared,TActual>() Method

Creates a dependency override where a specified actual type fulfills the contract of a declared type.

C#
public static Abblix.DependencyInjection.Dependency Override<TDeclared,TActual>()
    where TActual : TDeclared;

Type parameters

TDeclared

The declared type of the dependency.

TActual

The actual type to be used as the implementation.

Returns

Dependency
A new Dependency instance.

Dependency.Override<TDeclared>(Func<IServiceProvider,TDeclared>) Method

Creates a dependency override using a factory function for the declared type.

C#
public static Abblix.DependencyInjection.Dependency Override<TDeclared>(System.Func<System.IServiceProvider,TDeclared> factory);

Type parameters

TDeclared

The declared type of the dependency.

Parameters

factory System.Func<System.IServiceProvider,TDeclared>

The factory function to create the dependency instance.

Returns

Dependency
A new Dependency instance.

Dependency.Override<TDeclared>(TDeclared) Method

Creates a dependency override with a specific instance for the declared type.

C#
public static Abblix.DependencyInjection.Dependency Override<TDeclared>(TDeclared instance);

Type parameters

TDeclared

The declared type of the dependency.

Parameters

instance TDeclared

The instance to use for the dependency.

Returns

Dependency
A new Dependency instance.