Welcome to Simple Injector’s documentation!¶
Simple Injector is an easy-to-use Dependency Injection (DI) library for .NET that supports .NET Core, Xamarin, Mono and Universal apps. Simple Injector is easily integrated with frameworks such as Web API, MVC, WCF, ASP.NET Core and many others. It’s easy to implement the dependency injection pattern with loosely coupled components using Simple Injector.
Use:
Get official builds from NuGet or run the following command in the Package Manager Console: PM> Install-Package SimpleInjector
Browse the source code.
Browse questions on Stackoverflow and Github.
Engage:
Contents:
- Quick Start
- Using Simple Injector
- Object Lifetime Management
- Transient Lifestyle
- Singleton Lifestyle
- Scoped Lifestyle
- Thread Scoped Lifestyle
- Async Scoped Lifestyle (async/await)
- Web Request Lifestyle
- Async Scoped lifestyle vs. Web Request lifestyle
- WCF Operation Lifestyle
- Per Graph Lifestyle
- Instance Per Dependency Lifestyle
- Per Thread Lifestyle
- Per HTTP Session Lifestyle
- Hybrid Lifestyle
- Developing a Custom Lifestyle
- Generics and Lifetime Management
- Collections and Lifetime Management
- Flowing scopes
- Integration Guide
- Console Applications
- Using your DI Container during testing
- ASP.NET Core MVC
- ASP.NET Core 6 program.cs integration example
- ASP.NET Core Startup class integration example
- Available integration packages
- Wiring custom middleware
- Cross wiring ASP.NET and third-party services
- Working with IOptions<T>
- Using Hosted Services
- Using [FromServices] in ASP.NET Core MVC Controllers
- Resolving services from MVC’s ValidationContext
- Using Razor Pages
- Overriding the default IServiceScope Reuse Behavior
- Working with ASP.NET Core Identity
- .NET Generic Host
- ServiceCollection Console Applications
- Blazor Server App Integration
- Azure Functions Integration
- ASP.NET MVC
- ASP.NET Web API
- ASP.NET Web Forms
- OWIN
- Windows Forms
- WCF
- WPF
- Other Technologies
- Patterns
- Diagnostic Services
- How To
- Advanced Scenarios
- Generics
- Batch-Registration / Auto-Registration
- Registration of open-generic types
- Mixing collections of open-generic and non-generic components
- Unregistered type resolution
- Context-based injection
- Property injection
- Covariance and Contravariance
- Registering plugins dynamically
- Accessing a dependency’s metadata
- Aspect-Oriented Programming
- Decoration
- Applying Decorators conditionally
- Applying Decorators conditionally using type constraints
- Decorators with Func<T> decoratee factories
- Decorated collections
- Using contextual information inside decorators
- Applying decorators conditionally based on consumer
- Decorator registration factories
- Applying lifestyles to Decorators
- Interception using Dynamic Proxies
- Decoration
- Extensibility Points
- Overriding Constructor Resolution Behavior
- Overriding Property Injection Behavior
- Overriding Parameter Injection Behavior
- Resolving Unregistered Types
- Overriding Lifestyle Selection Behavior
- Intercepting the Creation of Types
- Building up External Instances
- Interception of Resolved Object Graphs
- Container-locking
- Simple Injector Pipeline
- Design Principles
- Design Decisions
- The container is locked after the first call to resolve
- The API clearly differentiates the registration of collections
- No support for XML based configuration
- Never force users to release what they resolve
- Don’t allow resolving scoped instances outside an active scope
- No out-of-the-box support for property injection
- No out-of-the-box support for dynamic interception
- Limited Auto-Registration API
- No per-thread lifestyle
- Allow only a single constructor
- No support for optional constructor arguments
- Legal stuff
- How to Contribute
- Appendix