A lightweight, fast, and portable dependency injection framework for .NET-based solutions.
WithRequiredMemberInjection()
registration and container configuration option to control the auto injection of required
members.required
members.DependencyName
attribute. When a parameter is marked with this attribute, the container will pass the given dependency's name to it.WithUniversalName()
container configuration method. It sets the universal name which is a special name that allows named resolution work for any given name.WithAdditionalDependencyNameAttribute()
container configuration method. It adds an attribute type that is considered a dependency name indicator just like the DependencyName
attribute.WithAdditionalDependencyAttribute()
container configuration method. It adds an attribute type that is considered a dependency indicator just like the Dependency
attribute.IEnumerable<T>
resolution call.TypeInformation
as a factory delegate input parameter. The TypeInformation
holds every reflected context information about the currently resolving type. This can be useful when the resolution is, e.g., in an open generic context, and we want to know which closed generic variant is requested.
container.Register(typeof(IService<>), options => options.WithFactory<TypeInformation>(typeInfo =>
{
/* typeInfo.Type holds the currently resolving closed generic type */
}));
ParentDependency
flag for ResolutionBehavior
. It indicates that parent containers (including indirect all ancestors) can only provide dependencies for services that are already selected for resolution..Register<IService>(c => c.WithFactory(/* ... */).AsServiceAlso<IAnother>())
. Now, the container gets the implementation type from the generic context where it's possible.Resolve()
method now accepts a ResolutionBehavior
flag parameter. It determines which level of the container hierarchy can take part in the service resolution. Possible values:
Parent
: Indicates that parent containers (including indirect all ancestors) can participate in the resolution request's service selection.Current
: Indicates that the current container (which initiated the resolution request) can participate in the service selection.Default
: The default behavior, it's used when the parameter is not specified. Its value is Parent | Current
, so the parents and the current (which initiated the resolution request) container can participate in the resolution request's service selection.CreateChildContainer()
now accepts an attachToParent
boolean parameter, which indicates whether the parent container's disposal should also dispose the child. It defaults to true
.ITenantDistributor
and TenantDistributor
types became obsolete. Their functionality is available on IStashboxContainer
.
ITenantDistributor.ConfigureTenant()
-> IStashboxContainer.CreateChildContainer()
ITenantDistributor.GetTenant()
-> IStashboxContainer.GetChildContainer()
Validate()
on a container will execute validation on each of its child container if it has any.IEnumerable<T>
and ResolveAll()
requests were not taking services in parent containers into account. Now, it respects the given ResolutionBehavior
and as its default value is Parent | Current
, IEnumerable<T>
requests will return services from parent containers by default.ResolutionBehavior
parameter.