Dependency Injection in .NET
Mark Seemann
Foreword by Glenn Block
  • October 2011
  • ISBN 9781935182504
  • 584 pages
  • printed in black & white

Realistic examples keep the big picture in focus...A real treat.

Glenn Block, Microsoft

Dependency Injection in .NET presents core DI patterns in plain C# so you'll fully understand how DI works, covers integration with standard Microsoft technologies like ASP.NET MVC, and teaches you to use DI frameworks like Structure Map, Castle Windsor, and Unity.

Table of Contents show full

foreword

preface acknowledgments about this book about the cover illustration

==

==

==

==

Part 1 Putting Dependency Injection on the map

1. Chapter 1 A Dependency Injection tasting menu

1.1. Writing maintainable code

1.2. Hello DI

1.3. What to inject and what not to inject

1.4. DI scope

1.5. Summary

2. Chapter 2 A comprehensive example

2.1. Doing it wrong

2.2. Doing it right

2.3. Expanding the sample application

2.4. Summary

3. Chapter 3 DI Containers

3.1. Introducing DI Containers

3.2. Configuring DI Containers

3.3. DI Container patterns

3.4. DI Container landscape

3.5. Summary

Part 2 DI catalog

4. Chapter 4 DI patterns

4.1. Constructor Injection

4.2. Property Injection

4.3. Method Injection

4.4. Ambient Context

4.5. Summary

5. Chapter 5 DI anti-patterns

5.1. Control Freak

5.2. Bastard Injection

5.3. Constrained Construction

5.4. Service Locator

5.5. Summary

6. Chapter 6 DI refactorings

6.1. Mapping runtime values to Abstractions

6.2. Working with short-lived Dependencies

6.3. Resolving cyclic Dependencies

6.4. Dealing with Constructor Over-injection

6.5. Monitoring coupling

6.6. Summary

Part 3 DIY DI

7. Chapter 7 Object Composition

7.1. Composing console applications

7.2. Composing ASP.NET MVC applications

7.3. Composing WCF applications

7.4. Composing WPF applications

7.5. Composing ASP.NET applications

7.6. Composing PowerShell cmdlets

7.7. Summary

8. Chapter 8 Object Lifetime

8.1. Managing Dependency Lifetime

8.2. Working with disposable Dependencies

8.3. Lifestyle catalog

8.4. Summary

9. Chapter 9 Interception

9.1. Introducing Interception

9.2. Implementing Cross-Cutting Concerns

9.3. Declaring aspects

9.4. Summary

Part 4 DI Containers

10. Chapter 10 Castle Windsor

10.1. Introducing Castle Windsor

10.2. Managing lifetime

10.3. Working with multiple components

10.4. Configuring difficult APIs

10.5. Summary

11. Chapter 11 StructureMap

11.1. Introducing StructureMap

11.2. Managing lifetime

11.3. Working with multiple components

11.4. Configuring difficult APIs

11.5. Summary

12. Chapter 12 Spring.NET

12.1. Introducing Spring.NET

12.2. Managing lifetime

12.3. Working with multiple components

12.4. Configuring difficult APIs

12.5. Summary

13. Chapter 13 Autofac

13.1. Introducing Autofac

13.2. Managing lifetime

13.3. Working with multiple components

13.4. Registering difficult APIs

13.5. Summary

14. Chapter 14 Unity

14.1. Introducing Unity

14.2. Managing lifetime

14.3. Working with multiple components

14.4. Configuring difficult APIs

14.5. Summary

15. Chapter 15 MEF

15.1. Introducing MEF

15.2. Managing lifetime

15.3. Working with multiple components

15.4. Composing difficult APIs

15.5. Summary

© 2014 Manning Publications Co.

About the Technology

Dependency Injection is a great way to reduce tight coupling between software components. Instead of hard-coding dependencies, such as specifying a database driver, you inject a list of services that a component may need. The services are then connected by a third party. This technique enables you to better manage future changes and other complexity in your software.

About the book

Dependency Injection in .NET introduces DI and provides a practical guide for applying it in .NET applications. The book presents the core patterns in plain C#, so you'll fully understand how DI works. Then you'll learn to integrate DI with standard Microsoft technologies like ASP.NET MVC, and to use DI frameworks like StructureMap, Castle Windsor, and Unity. By the end of the book, you'll be comfortable applying this powerful technique in your everyday .NET development.

What's inside

  • Many C#-based examples
  • A catalog of DI patterns and anti-patterns
  • Using both Microsoft and open source DI frameworks

About the reader

This book is written for C# developers. No previous experience with DI or DI frameworks is required.

About the author

Mark Seemann is a software architect living in Copenhagen. Previously a developer and architect at Microsoft, Mark is now an independent consultant.


combo $49.99 pBook + eBook
eBook $39.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

Well-written, thoughtful, easy to follow, and...timeless.

David Barkol, Neudesic, LLC

Fills a huge need for .NET designers.

Paul Grebenc, PCA Services, Inc.

Takes the mystery out of a mystifying topic.

Rama Krishna, 3C Software

All you need to know...and more!

Jonas Bandi, TechTalk