Info
Version: | 2.1.0 |
Author(s): | Skenja |
Last Update: | Sunday, June 25, 2017 |
.NET Fiddle: | Create the first Fiddle |
Project Url: | https://gitlab.com/Skenja/DependencyInjectionAssistant |
NuGet Url: | https://www.nuget.org/packages/DIAssistant |
Install
Install-Package DIAssistant
dotnet add package DIAssistant
paket add DIAssistant
DIAssistant Download (Unzip the "nupkg" after downloading)
Dependencies
Tags
with a single command, while still using any IoC you may wish, or sticking to the default MVC implementation.
In your Startup.cs file invoke BindDependencies() on IServicesCollection and pass in required parameters. Every Interface should inherit from IInjectable, and every implementation needs to have [Transient], [Scoped], or [Singleton] attribute on top.
Each of those parameters also takes environment input, which allows you to simply bind mocked implementations for running tests for example.
If you want to use an IoC container, create an implementation of IInjector interface and pass it in to the BindDependencies extension method called upon IServiceCollection via generic parameter.
I would suggest following 'Composition Root' pattern, it will both save you some headache and make all of this seem even easier than it already is.