-
Notifications
You must be signed in to change notification settings - Fork 10
Home
Peter Csajtai edited this page Jan 9, 2020
·
33 revisions
Stashbox is a lightweight, portable dependency injection framework for .NET based solutions.
- Fluent interface - for faster and easier configuration, attribute based and conventional resolution is also supported.
- Interface/implementation mapping - single service, instance registration, service remapping and replacing is also supported.
- Named registration - multiple implementations are identifiable with names.
- Assembly registration - service lookup in assemblies and auto determining the interface types.
- Factory delegate registration - factory delegate registration with parameters (used for dependency overriding).
- Open generic registration - closed generic types are constructed from open generic definitions with constraint and nested generic definition checking.
- Wiring into the container - further operations like member and method injection is executed on existing instances.
- Initializer / finalizer - custom initializer (called when a service is instantiated by the container) and finalizer (called when the container or scope which created the service is being disposed) actions can be set.
- Multiple service resolution - all registered implementation of a service can be obtained.
- Unknown type resolution - non-registered services can be resolved or injected.
- Default and optional value injection - primitive types or dependencies with default or optional values can be injected.
- Building up existing instances - member and method injection is executed on existing instances without wiring them into the container.
- Child containers - building up and maintaining the parent/child hierarchy between the containers.
- Lifetime scopes - maintaining the lifetime of scoped registrations.
-
Lifetime management -
Singleton
,Scoped
,NamedScope
andPerResolutionRequest
are built-in, but custom, user-defined lifetimes are supported as well. - Conditional resolution - attribute, parent-type and custom, user-defined conditions can be specified.
-
IDisposable object tracking -
IDisposable
objects are disposed by the container. -
Circular dependency tracking - the container checks the resolution graph for circular dependencies and it throws a specific
CircularDependencyException
if it finds any. -
Generic wrappers
- Collections: everything assignable to
IEnumerable<T>
e.g.T[]
,ICollection<T>
,IReadOnlyCollection<T>
,IList<T>
etc. -
Lazy<>
,Func<>
,Tuple<>
-
Parameter injection over delegate arguments (e.g.
Func<TParam, TService>
,Func<TParam1, TParam2, TService>
) applied to subdependencies as well. - Nested wrappers like
Tuple<TService, IEnumerable<Func<TParam, Lazy<TService1>>>>
.
- Collections: everything assignable to
- Custom resolvers - the existing activation rutines are extendable with custom resolvers.
- Container extensions - the functionality of the container is extendable with custom extensions, e.g. Auto configuration parser extension
- Custom configuration - the behavior of the container can be controlled by custom configuration options.
-
Graph validation - the resolution graph can be validated by calling the
Validate()
function of the container. - Decorator support / Interception - decorator services can be registered and used for interception with Castle DynamicProxy.
- Service registration
- Factory registration
- Assembly registration
- Composition
- Fluent registration api
- Service resolution
- Resolution by attributes
- Conventional resolution
- Delegate resolution
- Conditional resolution
- Multi resolution
- Lifetimes
- Generics
- Generic wrappers
- Decorators
- Resolvers
- Scopes
- Container configuration
- Container diagnostics
- Exceptions