Table of Contents

Class DependencyContainerBuilder

Namespace
LfrlAnvil.Dependencies
Assembly
LfrlAnvil.Dependencies.dll

Represents an IDisposableDependencyContainer builder.

public class DependencyContainerBuilder : IDependencyContainerBuilder, IDependencyLocatorBuilder
Inheritance
DependencyContainerBuilder
Implements
Inherited Members
Extension Methods

Constructors

DependencyContainerBuilder()

Creates a new empty DependencyContainerBuilder instance.

public DependencyContainerBuilder()

Properties

Configuration

Represents the current configuration.

public IDependencyContainerConfigurationBuilder Configuration { get; }

Property Value

IDependencyContainerConfigurationBuilder

DefaultDisposalStrategy

Specifies the default implementor disposal strategy for this locator.

public DependencyImplementorDisposalStrategy DefaultDisposalStrategy { get; }

Property Value

DependencyImplementorDisposalStrategy

DefaultLifetime

Specifies the default dependency lifetime for this locator.

public DependencyLifetime DefaultLifetime { get; }

Property Value

DependencyLifetime

Methods

Add(Type)

Creates a new IDependencyBuilder instance for the provided type.

public IDependencyBuilder Add(Type type)

Parameters

type Type

Dependency type.

Returns

IDependencyBuilder

New IDependencyBuilder instance.

Remarks

This may also create an IDependencyRangeBuilder instance if it did not exist yet for the provided type.

Exceptions

InvalidTypeRegistrationException

When the provided type is a generic type definition or contains generic parameters.

AddSharedImplementor(Type)

Gets or creates a new IDependencyImplementorBuilder instance for the provided type.

public IDependencyImplementorBuilder AddSharedImplementor(Type type)

Parameters

type Type

Shared implementor type.

Returns

IDependencyImplementorBuilder

New IDependencyImplementorBuilder instance or an existing instance.

Exceptions

InvalidTypeRegistrationException

When the provided type is a generic type definition or contains generic parameters.

GetDependencyRange(Type)

Gets or creates a new IDependencyRangeBuilder instance for the provided element type.

[Pure]
public IDependencyRangeBuilder GetDependencyRange(Type type)

Parameters

type Type

Element type.

Returns

IDependencyRangeBuilder

New IDependencyRangeBuilder instance or an existing instance.

Exceptions

InvalidTypeRegistrationException

When the provided element type is a generic type definition or contains generic parameters.

GetKeyedLocator<TKey>(TKey)

Gets or adds a keyed IDependencyLocatorBuilder<TKey> instance.

public IDependencyLocatorBuilder<TKey> GetKeyedLocator<TKey>(TKey key) where TKey : notnull

Parameters

key TKey

Locator's key.

Returns

IDependencyLocatorBuilder<TKey>

Existing IDependencyLocatorBuilder<TKey> or an added one.

Type Parameters

TKey

Key type.

SetDefaultDisposalStrategy(DependencyImplementorDisposalStrategy)

Sets the DefaultDisposalStrategy of this instance.

public DependencyContainerBuilder SetDefaultDisposalStrategy(DependencyImplementorDisposalStrategy strategy)

Parameters

strategy DependencyImplementorDisposalStrategy

Default strategy to set.

Returns

DependencyContainerBuilder

this.

SetDefaultLifetime(DependencyLifetime)

Sets the DefaultLifetime of this instance.

public DependencyContainerBuilder SetDefaultLifetime(DependencyLifetime lifetime)

Parameters

lifetime DependencyLifetime

Default lifetime to set.

Returns

DependencyContainerBuilder

this.

TryBuild()

Attempts to build an IDisposableDependencyContainer instance.

[Pure]
public DependencyContainerBuildResult<DependencyContainer> TryBuild()

Returns

DependencyContainerBuildResult<DependencyContainer>

DependencyContainerBuildResult<TContainer> instance with the build attempt result.

TryGetSharedImplementor(Type)

Attempts to get an IDependencyImplementorBuilder instance associated with the provided type.

[Pure]
public IDependencyImplementorBuilder? TryGetSharedImplementor(Type type)

Parameters

type Type

Type to get the shared implementor builder for.

Returns

IDependencyImplementorBuilder

IDependencyImplementorBuilder instance associated with the provided type or null when it does not exist.