Mastering Ninject for Dependency Injection
暫譯: 精通 Ninject 依賴注入
Daniel Baharestani
- 出版商: Packt Publishing
- 出版日期: 2013-08-29
- 售價: $1,590
- 貴賓價: 9.5 折 $1,511
- 語言: 英文
- 頁數: 142
- 裝訂: Paperback
- ISBN: 1782166203
- ISBN-13: 9781782166207
海外代購書籍(需單獨結帳)
商品描述
For .NET developers and architects, this is the ultimate guide to the principles of Dependency Injection and how to use the automating features of Ninject in the most effective way. Packed with examples, diagrams, and illustrations.
Overview
- Create loosely coupled applications by implementing dependency injection using Ninject
- Learn how to design an enterprise application so as to maximize its maintainability, extensibility and testability
- Automate the process of dealing with the dependencies of your application and object lifetimes
- Address the cross-cutting concerns of your applications in the easiest way
- Full of real-life, step-by-step examples and clear code samples
In Detail
Dependency injection is an approach to creating loosely coupled applications. Maintainability, testability, and extensibility are just a few advantages of loose coupling. Ninject is a software library which automates almost everything that we need in order to implement a dependency injection pattern.
Mastering Ninject for Dependency Injection will teach you everything you need to know in order to implement dependency injection using Ninject in a real-life project. Not only does it teach you about Ninject core framework features that are essential for implementing dependency injection, but it also explores the power of Ninject’s most useful extensions and demonstrates how to apply them.
Mastering Ninject for Dependency Injection starts by introducing you to dependency injection and what it’s meant for with the help of sufficient examples.
Eventually, you’ll learn how to integrate Ninject into your practical project and how to use its basic features. Also, you will go through scenarios wherein advanced features of Ninject, such as Multi-binding, Contextual binding, providers, factories and so on, come into play. As you progress, Mastering Ninject for Dependency Injection will show you how to create a multilayer application that demonstrates the use of Ninject on different application types such as MVC, WPF, WCF, and so on. Finally, you will learn the benefits of using the powerful extensions of Ninject.
What you will learn from this book
- Understand dependency injection, how it is different from similar patterns such as inversion of control, and the problems that it addresses
- Set up Ninject in an application and configure it either using XML or programmatically
- Learn how to control object life-time by configuring object scopes
- Wire up abstract service types to concrete implementations using bindings
- Create plugins to add new features to compiled applications dynamically
- Use Ninject in different application types such as Win Forms, Web Forms, WPF, Silverlight, ASP.NET MVC, and WCF
- Inject common loggers such as log4net and NLog automatically into application components
- Test application units and automate the injection of mock objects by integrating Ninject with common mock frameworks (for example Moq or Rhino Mock)
- Register hundreds of bindings in a single line of code using the Convention configuration
- Inject the implementation of cross-cutting concerns such as logging, exception handling, or caching by interception
Approach
Mastering Ninject for Dependency Injection teaches you the most powerful concepts of Ninject in a simple and easy-to-understand format using lots of practical examples, diagrams, and illustrations.
商品描述(中文翻譯)
對於 .NET 開發人員和架構師來說,這是關於依賴注入原則的終極指南,以及如何以最有效的方式使用 Ninject 的自動化功能。內容充滿了範例、圖表和插圖。
概述
- 通過使用 Ninject 實現依賴注入來創建鬆耦合的應用程序
- 學習如何設計企業應用程序,以最大化其可維護性、可擴展性和可測試性
- 自動化處理應用程序的依賴關係和對象生命週期的過程
- 以最簡單的方式解決應用程序的橫切關注點
- 充滿真實的逐步範例和清晰的代碼範本
詳細內容
依賴注入是一種創建鬆耦合應用程序的方法。可維護性、可測試性和可擴展性只是鬆耦合的一些優勢。Ninject 是一個自動化幾乎所有我們需要的軟體庫,以實現依賴注入模式。
掌握 Ninject 以進行依賴注入將教會你在實際項目中使用 Ninject 實現依賴注入所需了解的一切。它不僅教你 Ninject 核心框架的特性,這些特性對於實現依賴注入至關重要,還探討了 Ninject 最有用的擴展的強大功能,並演示如何應用它們。
掌握 Ninject 以進行依賴注入首先通過足夠的範例向你介紹依賴注入及其用途。
最終,你將學會如何將 Ninject 整合到你的實際項目中,以及如何使用其基本功能。此外,你將經歷一些場景,其中 Ninject 的高級功能,如多重綁定、上下文綁定、提供者、工廠等,將發揮作用。隨著進展,掌握 Ninject 以進行依賴注入將向你展示如何創建一個多層應用程序,該應用程序展示了 Ninject 在不同應用類型(如 MVC、WPF、WCF 等)上的使用。最後,你將學習使用 Ninject 強大擴展的好處。
你將從這本書中學到什麼
- 理解依賴注入,它與控制反轉等類似模式的不同之處,以及它所解決的問題
- 在應用程序中設置 Ninject,並使用 XML 或以編程方式進行配置
- 學習如何通過配置對象範圍來控制對象生命週期
- 使用綁定將抽象服務類型連接到具體實現
- 創建插件以動態為已編譯的應用程序添加新功能
- 在不同的應用類型中使用 Ninject,例如 Win Forms、Web Forms、WPF、Silverlight、ASP.NET MVC 和 WCF
- 自動將常見的日誌記錄器(如 log4net 和 NLog)注入到應用程序組件中
- 測試應用程序單元,並通過將 Ninject 與常見的模擬框架(例如 Moq 或 Rhino Mock)集成來自動注入模擬對象
- 使用約定配置在一行代碼中註冊數百個綁定
- 通過攔截注入橫切關注點的實現,例如日誌記錄、異常處理或緩存
方法
掌握 Ninject 以進行依賴注入以簡單易懂的格式教你 Ninject 最強大的概念,並使用大量實用範例、圖表和插圖。