Dependency Injection in .NET Core

Key FeaturesIdentify when to use the Constructor, Parameter, Setter, or Interface Injection, for best resultsBuild dependencies not only for MVC within .NET but also for other front-end tools such as AngularCreate specific components or services to cover discrete and separate pieces of functionality and call them when needed.Book Description.NET Core provides more control than ever over web application architecture. Under this view of software architecture, one key point is that it's based on the use of Dependency Injection, as a way to properly implement the Dependency Inversion principle proposed in the SOLID principles established by Robert C. Martin.With the advent of .NET Core, things have become much simpler with DI built into the system. This book aims to give you a profound insight into writing loosely-coupled code using the latest features available in .NET Core. It will talk about Constructor, Parameter, Setter, and Interface Injection, explaining in detail, with the help of examples, which type of injection to use in which situation. It will show you how to implement a class that creates other classes with associated dependencies, also called IoC containers, and then create dependencies for each of the MVC components of ASP.NET Core. You'll learn to distinguish between IoC containers, the use of Inversion of Control, and DI itself, since DI is just a way of implementing IoC via these containers. You'll also learn how to build dependencies for any other front-end tool such as Angular. You will get to use the in-built services offered by .NET Core and create your own custom dependencies.Towards the end, we'll talk about some patterns and anti-patterns for Dependency Injection along with some techniques to refactor legacy applications and inject dependencies.What you will learnUnderstand the concept of DI and its implications in modern software constructionLearn how DI is already implemented in today's frameworks.Analyze how DI can be used with current software to improve maintainability and scalability.Learn the use of DI available in .NET CoreGet used to the possibilities that DI offers to the ASP.NET Core developer in different scenarios.Learn about good practices and refactoring legacy code.

Author: Marino Posadas

Learn more

Deals