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一無所知並希望瞭解如何在應用程序中實施DI的C#和.NET開發人員

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

詳細內容
.NET Core提供了比以往更多的控制權,特別是在Web應用程式架構方面。這種軟體架構的關鍵點是基於依賴注入的使用,作為正確實現Robert C. Martin所提出的SOLID原則中的依賴反轉原則的方式。

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

最後,我們將討論一些依賴注入的模式和反模式,以及一些重構遺留應用程式和注入依賴的技術。

風格和方法
本書充滿了示例,將引導您通過使用框架或不使用框架的各種技術將依賴項注入到應用程式中。