Dependency Injection in .NET Core 2.0

Inject dependencies and write highly maintainable and flexible code using the new .NET Core DI Engine
Preview in Mapt

Dependency Injection in .NET Core 2.0

Marino Posadas, Tadit Dash

Inject dependencies and write highly maintainable and flexible code using the new .NET Core DI Engine
Mapt Subscription
FREE
$29.99/m after trial
eBook
$10.00
RRP $39.99
Save 74%
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$10.00
$49.99
$29.99 p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Dependency Injection in .NET Core 2.0 Book Cover
Dependency Injection in .NET Core 2.0
$ 39.99
$ 10.00
Building Microservices with .NET Core 2.0 - Second Edition Book Cover
Building Microservices with .NET Core 2.0 - Second Edition
$ 35.99
$ 10.00
Buy 2 for $20.00
Save $55.98
Add to Cart

Book Details

ISBN 139781787121300
Paperback436 pages

Book Description

.NET Core provides more control than ever over web application architectures. A key point of this software architecture 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 Dependency Injection 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 talks about constructors, parameter, setters, 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 MVC component 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 other frontend tool such as Angular. You will get to use the in-built services offered by .NET Core to 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.

Table of Contents

Chapter 1: The SOLID Principles of Software Design
In the beginning
The SOLID principles
Another sample
The Open/Closed principle
Back to our sample
The Liskov Substitution principle
The Interface Segregation principle
Another sample
The Dependency Inversion principle
The (more or less) canonical example
Other ways to implement Dependency Inversion
Summary
Chapter 2: Dependency Injection and IoC Containers
The Dependency Principle in more detail
Aspects of Dependency Injection
Ways to implement DI
DI containers
Dependency Injection in other frameworks
Summary
Chapter 3: Introducing Dependency Injection in .NET Core 2.0
The main characteristics of .NET Core
The main advantages of .NET Core
Dependency Injection in .NET Core
Summary
Chapter 4: Dependency Injection in ASP.NET Core
ASP.NET Core from the command-line tools
The Startup class and Dependency Injection
The New ASP.NET servers
Analyzing the default template
Dependency Injection in ASP.NET Core
Summary
Chapter 5: Object Composition
Understanding object relationships
Object Composition
Composition versus Aggregation
Composition over Inheritance
Role of Object Composition in Dependency Injection
Composing .NET Core 2.0 Console application
Object Composition in ASP.NET Core MVC 2.0
Summary
Chapter 6: Object Lifetime
Manage the object life cycle
Object lifetime management in .NET Core
Summary
Chapter 7: Interception
Introducing Interception
Aspect-oriented programming
Investigating Interception
Intermediate Language (IL) Weaving
Interception in ASP.NET Core
Summary
Chapter 8: Patterns - Dependency Injection
Dependency Inversion Principle
Patterns
Summary
Chapter 9: Anti-Patterns and Misconceptions on Dependency Injection
When does Dependency Injection become an anti-pattern?
Anti-patterns
Summary
Chapter 10: Dependency Injection in Other JavaScript Frameworks
TypeScript
Architectural changes
Angular
Angular 2+
Summary
Chapter 11: Best Practices and Other Related Techniques
Tightly coupled systems
Layered architecture
Summary

What You Will Learn

  • Understand the concept of DI and its implications in modern software construction
  • Learn 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 in .NET Core
  • Get used to the possibilities that DI offers the ASP.NET Core developer in different scenarios.
  • Learn about good practices and refactoring legacy code.

Authors

Table of Contents

Chapter 1: The SOLID Principles of Software Design
In the beginning
The SOLID principles
Another sample
The Open/Closed principle
Back to our sample
The Liskov Substitution principle
The Interface Segregation principle
Another sample
The Dependency Inversion principle
The (more or less) canonical example
Other ways to implement Dependency Inversion
Summary
Chapter 2: Dependency Injection and IoC Containers
The Dependency Principle in more detail
Aspects of Dependency Injection
Ways to implement DI
DI containers
Dependency Injection in other frameworks
Summary
Chapter 3: Introducing Dependency Injection in .NET Core 2.0
The main characteristics of .NET Core
The main advantages of .NET Core
Dependency Injection in .NET Core
Summary
Chapter 4: Dependency Injection in ASP.NET Core
ASP.NET Core from the command-line tools
The Startup class and Dependency Injection
The New ASP.NET servers
Analyzing the default template
Dependency Injection in ASP.NET Core
Summary
Chapter 5: Object Composition
Understanding object relationships
Object Composition
Composition versus Aggregation
Composition over Inheritance
Role of Object Composition in Dependency Injection
Composing .NET Core 2.0 Console application
Object Composition in ASP.NET Core MVC 2.0
Summary
Chapter 6: Object Lifetime
Manage the object life cycle
Object lifetime management in .NET Core
Summary
Chapter 7: Interception
Introducing Interception
Aspect-oriented programming
Investigating Interception
Intermediate Language (IL) Weaving
Interception in ASP.NET Core
Summary
Chapter 8: Patterns - Dependency Injection
Dependency Inversion Principle
Patterns
Summary
Chapter 9: Anti-Patterns and Misconceptions on Dependency Injection
When does Dependency Injection become an anti-pattern?
Anti-patterns
Summary
Chapter 10: Dependency Injection in Other JavaScript Frameworks
TypeScript
Architectural changes
Angular
Angular 2+
Summary
Chapter 11: Best Practices and Other Related Techniques
Tightly coupled systems
Layered architecture
Summary

Book Details

ISBN 139781787121300
Paperback436 pages
Read More

Read More Reviews

Recommended for You

C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition Book Cover
C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition
$ 39.99
$ 10.00
Mastering ASP.NET Core 2.0 Book Cover
Mastering ASP.NET Core 2.0
$ 39.99
$ 10.00
C# 7 and .NET Core 2.0 Blueprints Book Cover
C# 7 and .NET Core 2.0 Blueprints
$ 35.99
$ 10.00
C# 7 and .NET Core Cookbook Book Cover
C# 7 and .NET Core Cookbook
$ 39.99
$ 10.00
Learning ASP.NET Core 2.0 Book Cover
Learning ASP.NET Core 2.0
$ 35.99
$ 10.00
Building Microservices with .NET Core 2.0 - Second Edition Book Cover
Building Microservices with .NET Core 2.0 - Second Edition
$ 35.99
$ 10.00