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
DefaultDisposalStrategy
Specifies the default implementor disposal strategy for this locator.
public DependencyImplementorDisposalStrategy DefaultDisposalStrategy { get; }
Property Value
DefaultLifetime
Specifies the default dependency lifetime for this locator.
public DependencyLifetime DefaultLifetime { get; }
Property Value
Methods
Add(Type)
Creates a new IDependencyBuilder instance for the provided type.
public IDependencyBuilder Add(Type type)
Parameters
typeTypeDependency 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
typeis 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
typeTypeShared implementor type.
Returns
- IDependencyImplementorBuilder
New IDependencyImplementorBuilder instance or an existing instance.
Exceptions
- InvalidTypeRegistrationException
When the provided
typeis 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
typeTypeElement type.
Returns
- IDependencyRangeBuilder
New IDependencyRangeBuilder instance or an existing instance.
Exceptions
- InvalidTypeRegistrationException
When the provided element
typeis 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
keyTKeyLocator's key.
Returns
- IDependencyLocatorBuilder<TKey>
Existing IDependencyLocatorBuilder<TKey> or an added one.
Type Parameters
TKeyKey type.
SetDefaultDisposalStrategy(DependencyImplementorDisposalStrategy)
Sets the DefaultDisposalStrategy of this instance.
public DependencyContainerBuilder SetDefaultDisposalStrategy(DependencyImplementorDisposalStrategy strategy)
Parameters
strategyDependencyImplementorDisposalStrategyDefault strategy to set.
Returns
SetDefaultLifetime(DependencyLifetime)
Sets the DefaultLifetime of this instance.
public DependencyContainerBuilder SetDefaultLifetime(DependencyLifetime lifetime)
Parameters
lifetimeDependencyLifetimeDefault lifetime to set.
Returns
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
typeTypeType to get the shared implementor builder for.
Returns
- IDependencyImplementorBuilder
IDependencyImplementorBuilder instance associated with the provided
typeor null when it does not exist.