Giter Club home page Giter Club logo

stashbox's Introduction

stashbox Appveyor build status Travis CI build status Tests Coverage Status Quality Gate Sourcelink

Stashbox is a lightweight, portable dependency injection framework for .NET based solutions. Join the chat at https://gitter.im/z4kn4fein/stashbox Slack

Github (stable) NuGet (stable) MyGet (pre-release) Open Hub
Github release NuGet Version MyGet package OpenHub

Features

  • Fluent interface - for faster and easier configuration, attribute based configuration is supported also.
  • Interface/type mapping - single service, instance registration, remapping of existing registrations.
  • Resolution via delegates - dynamic dependency overrides with delegate parameters.
  • Keyed registrations - multiple implementations identified with a key for the same service type.
  • Assembly registration - service lookup in assemblies with auto determined service types.
  • Factory registration - factory delegates with several parameters can be registered.
  • Initializer / finalizer - custom initializer and finalizer actions can be set.
  • Multiple service resolution - all implementation registered for an interface can be obtained.
  • Unknown type resolution - unregistered services can be resolved or injected.
  • Default and optional value injection - primitive types or dependencies with default or optional value can be resolved.
  • Open generic type resolution - concrete generic types can be resolved from open generic definitions with constraint and nested generic definition checking.
  • Constructor, property and field injection - attribute driven resolution or automatic injection, when there is no chance to decorate members with attributes.
  • Injection method - methods decorated with InjectionMethod attribute are called at resolution time.
  • Wiring into container - member injection can be executed on existing instances.
  • Building up existing instance - member injection can be executed on existing instances without wiring them into the container.
  • Child container - parent/child container support.
  • Lifetime scopes - hierarchical/named scoping support.
  • Lifetime management - including Singleton, Transient, Scoped, NamedScope and PerResolutionRequest lifetime, custom user-defined lifetimes also can be used.
  • Conditional resolution - attribute, parent-type and custom user defined conditions can be specified.
  • IDisposable object tracking - IDisposable objects are being disposed by the container.
  • Cleanup delegates - custom finalizer delegate can be configured to be called when the container or scope which created the service is being disposed.
  • Circular dependency tracking - the container checks the resolution graph for circular dependencies, it throws a specific excpetion if it finds any.
  • Special types - 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>, etc. applied to subdependencies as well.
    • Nested wrappers e.g. Tuple<TService, IEnumerable<Func<TParam, Lazy<TService1>>>>.
  • Custom resolvers - the existing activation rutines can be extended with custom resolvers.
  • Container extensions - the containers functionality can be extended with custom extensions, e.g. Auto configuration parser extension
  • Custom configuration - the behavior of the container can be controlled with custom configurations.
  • Container validation - the resolution graph can be validated by calling the Validate() function.
  • Decorator support / Interception - decorator services can be registered and used for interception with Castle DynamicProxy

Supported platforms

  • .NET 4.0 and above
  • Windows 8/8.1/10
  • Windows Phone Silverlight 8/8.1
  • Windows Phone 8.1
  • Xamarin (Android/iOS/iOS Classic)
  • .NET Standard 1.0
  • .NET Standard 1.3
  • .NET Standard 2.0

Sample usage

class Wulfgar : IBarbarian
{
    public Wulfgar(IWeapon weapon)
    {
        //...
    }
}

var container = new StashboxContainer();

container.Register<IWeapon, AegisFang>();
container.Register<IBarbarian, Wulfgar>();

var wulfgar = container.Resolve<IBarbarian>();

Extensions

Documentation

Benchmarks


Powered by Jetbrains' Open Source License

Jetbrains

stashbox's People

Contributors

z4kn4fein avatar

Watchers

James Cloos avatar Vlad Vizitu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.