Mastering Ninject for Dependency Injection
Daniel Baharestani
- 出版商: Packt Publishing
- 出版日期: 2013-08-29
- 售價: $1,570
- 貴賓價: 9.5 折 $1,492
- 語言: 英文
- 頁數: 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)整合,自動注入模擬物件
- 使用 Convention 配置在一行程式碼中註冊數百個綁定
- 通過攔截注入橫切關注點的實現,例如日誌記錄、異常處理或快取
方法
掌握 Ninject 以進行依賴注入以簡單易懂的格式教你 Ninject 最強大的概念,並使用大量實用範例、圖表和插圖。