Dependency Injection in .NET Core 2.0: Make use of constructors, parameters, setters, and interface injection to write reusable and loosely-coupled code
暫譯: .NET Core 2.0 中的依賴注入:利用建構函數、參數、屬性和介面注入撰寫可重用且低耦合的程式碼

Marino Posadas, Tadit Dash

  • 出版商: Packt Publishing
  • 出版日期: 2017-11-10
  • 定價: $1,650
  • 售價: 6.0$990
  • 語言: 英文
  • 頁數: 436
  • 裝訂: Paperback
  • ISBN: 1787121305
  • ISBN-13: 9781787121300
  • 相關分類: .NET
  • 立即出貨 (庫存=1)

買這商品的人也買了...

相關主題

商品描述

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

About This Book

  • Identify when to use the constructors, parameters, setters, or Interface Injection, for best results
  • Build dependencies not only for MVC within .NET but also for other frontend tools such as Angular
  • Create specific components or services to cover discrete and separate pieces of functionality and call them when needed.

Who This Book Is For

C# and .NET developers who have no idea what DI is and would like to understand how to implement it in their applications.

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.

In Detail

.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.

Style and Approach

Filled with examples, this book will take you through various techniques for injecting dependencies into your applications with or without the use of frameworks.

商品描述(中文翻譯)

**注入依賴並使用新的 .NET Core DI 引擎編寫高度可維護和靈活的代碼**

## 本書介紹
- 確定何時使用建構函數、參數、設置器或介面注入,以獲得最佳結果
- 為 .NET 中的 MVC 構建依賴,還有其他前端工具,如 Angular
- 創建特定的組件或服務,以涵蓋獨立和分離的功能,並在需要時調用它們。

## 本書適合誰
本書適合對 DI 一無所知的 C# 和 .NET 開發人員,並希望了解如何在其應用程序中實現 DI。

## 您將學到什麼
- 理解 DI 的概念及其在現代軟體建構中的影響
- 學習當今框架中如何實現 DI。
- 分析如何使用 DI 來改善當前軟體的可維護性和可擴展性。
- 學習在 .NET Core 中使用 DI
- 熟悉 DI 為 ASP.NET Core 開發人員在不同場景中提供的可能性。
- 學習良好的實踐和重構舊代碼。

## 詳細內容
.NET Core 提供了比以往更多的控制權來管理網頁應用程序架構。這種軟體架構的一個關鍵點是,它基於使用依賴注入(Dependency Injection)來正確實現由 Robert C. Martin 提出的 SOLID 原則中的依賴反轉原則。

隨著 .NET Core 的出現,依賴注入變得更加簡單,因為它已內建於系統中。本書旨在深入探討如何使用 .NET Core 中可用的最新功能編寫鬆耦合的代碼。它討論了建構函數、參數、設置器和介面注入,詳細解釋了在不同情況下應使用哪種類型的注入,並通過示例進行說明。它將向您展示如何實現一個創建其他類及其相關依賴的類,這也稱為 IoC 容器,然後為 ASP.NET Core 的每個 MVC 組件創建依賴。您將學會區分 IoC 容器、控制反轉的使用以及 DI 本身,因為 DI 只是通過這些容器實現 IoC 的一種方式。您還將學習如何為其他前端工具如 Angular 構建依賴。您將使用 .NET Core 提供的內建服務來創建自己的自定義依賴。

在結尾部分,我們將討論一些依賴注入的模式和反模式,以及一些重構舊應用程序和注入依賴的技術。

## 風格與方法
本書充滿了示例,將帶您了解各種技術,無論是否使用框架,如何將依賴注入到您的應用程序中。