Table of Contents

Class BagContainerBuilder

Namespace
Mokkit.Containers.Bag
Assembly
Mokkit.Containers.Bag.dll

Builds a Mokkit.Containers.Bag.BagContainer — a minimal type-to-object container with no external DI dependency and no auto-wiring. Register pre-built instances with Mokkit.Containers.Bag.BagContainerBuilder.AddInstance``1(``0) or per-scope values with Mokkit.Containers.Bag.BagContainerBuilder.AddFactory``1(System.Func{``0}), either directly on the builder or from a Mokkit.Containers.Bag.BagContainerBuilder.UseInit(System.Func{Mokkit.Containers.Bag.IBagRegistrar,System.Threading.Tasks.Task}) callback.

public class BagContainerBuilder : IDependencyContainerBuilder, IBagRegistrar

Inheritance

Implements

Inherited Members

Methods

AddFactory<T>(Func<T>)

Registers a factory producing a value resolved by its type T. The factory is invoked at most once per scope; the value is disposed on scope disposal if it is System.IDisposable.

public BagContainerBuilder AddFactory<T>(Func<T> factory) where T : class

Parameters

factory Func<T>

The factory that creates the value.

Returns

BagContainerBuilder

The builder for fluent chaining.

Type Parameters

T

The type under which the produced value is resolved.

AddInstance<T>(T)

Registers a pre-built instance to be resolved by its own type T. The instance is shared across all scopes and is not disposed by the container.

public BagContainerBuilder AddInstance<T>(T instance) where T : class

Parameters

instance T

The instance to store.

Returns

BagContainerBuilder

The builder for fluent chaining.

Type Parameters

T

The type under which the instance is resolved.

TryGetCollection<TCollection>()

Attempts to retrieve this builder's registration surface for cross-builder coordination.

public TCollection? TryGetCollection<TCollection>() where TCollection : class

Returns

TCollection?

This builder cast to TCollection, or null if the cast is not possible.

Type Parameters

TCollection

The requested collection type.

UseInit(Func<IBagRegistrar, Task>)

Configures a callback that registers services during the initialization phase, mirroring the UseInit style of the other Mokkit container builders.

public BagContainerBuilder UseInit(Func<IBagRegistrar, Task> fn)

Parameters

fn Func<IBagRegistrar, Task>

The registration callback, receiving the bag registrar.

Returns

BagContainerBuilder

The builder for fluent chaining.