Dependency Injection in C# and .NET with the Autofac Library
4.7 (79 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
893 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Dependency Injection in C# and .NET with the Autofac Library to your Wishlist.

Add to Wishlist

Dependency Injection in C# and .NET with the Autofac Library

An in-depth course on Dependency Injection and Inversion of Control
Best Seller
4.7 (79 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
893 students enrolled
Created by Dmitri Nesteruk
Last updated 8/2017
English
Current price: $10 Original price: $50 Discount: 80% off
5 hours left at this price!
30-Day Money-Back Guarantee
Includes:
  • 5 hours on-demand video
  • 1 Article
  • 26 Supplemental Resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I Learn?
  • Understand and leverage the benefits of dependency injection
  • Plan and configure dependency injection containers
  • Leverage dependency injection scopes, modules and other advanced capabilities
  • Integrate dependency injection with popular frameworks (e.g., ASP.NET
View Curriculum
Requirements
  • Confident knowledge of C# and .NET
  • Good knowledge of object-oriented programming principles
  • Confident use of an IDE (e.g., Visual Studio)
Description

This is a course covering Dependency Injection in .NET using the Autofac library. The goal of the course is to provide in-depth coverage of the concept of dependency injection and give examples of how DI/IoC is used in the modern world.

This course covers the following topics:

  • The concepts of Dependency Injection and Inversion of Control and what they are for
  • Components and Services (terminology used by the Autofac container)
  • Component Registration including assembly and module scanning
  • Controlling Scope and Lifetime
  • Configuration including XML/JSON and Modules
  • Plenty of advanced topics for the connoisseur 



    Who is the target audience?
    • Beginner and Experienced .NET/C# Developers
    • Anyone interested in modern approaches to Dependency Injection
    Compare to Other Dependency Injection Courses
    Curriculum For This Course
    55 Lectures
    05:08:20
    +
    Introduction
    1 Lecture 02:39

    At look at what's included in this course.

    Preview 02:39
    +
    Dependency Injection and Inversion of Control
    3 Lectures 21:51

    Let's get familiar with the two key terms: DI and IoC.

    Dependency Injection and Inversion of Control
    16:15

    A discussion of the different DI frameworks that exist. There are many!

    An Overview of DI Frameworks
    04:21

    How to install and start using Autofac. Very easy, actually, since Autofac is available on NuGet.

    Getting Started with Autofac
    01:15
    +
    Registration Concepts
    9 Lectures 40:00

    Time to get started learning Autofac. Here's what we've got in store for this section.

    Overview
    03:34

    The key scenario which we're going to be using throughout most of the lessons in this course. No dependency injection yet, that will come in the next lesson!

    Scenario (Without DI)
    06:49

    Time to use Autofac! We register some components and watch the container weave its magic.

    Registering Types (Reflection Components)
    07:16

    What happens if you register multiple components for the ILog service?

    Default Registrations
    04:23

    If your class has multiple constructors, how does the container know which one to call?

    Preview 02:50

    Instead of registering a type to be created on demand, you can define an existing instance to be used whenever a component of a particular type is required.

    Registering Instances (Instance Components)
    02:42

    You can make component registrations using lambda expressions instead of type parameters. This affords additional flexibility.

    Preview 04:17

    What happens when you try to register (and subsequently resolve) generic types?

    Open Generic Components
    03:08

    A summary of all the things we've learned in this section of the course.

    Summary
    05:01

    Check your comprehension of this section.

    Registration Concepts Quiz
    5 questions
    +
    Advanced Registration Concepts
    6 Lectures 39:19

    An overview of the things we're going to encounter in this section of the course.

    Overview
    02:17

    We look at how parameters can be explicitly passed into the constructor of the instantiated component at the registration stage. We also look at an example of a lambda expression component that delays parameter value passing until the resolution stage.

    Passing Parameters to Register()
    12:25

    The constructor is the default way of adding dependencies, but you can also inject them into properties or specify methods that explicitly assign the dependencies.

    Property and Method Injection
    08:58

    Registering components one by one is tedious. How about registering all components from an assembly?

    Scanning for Types
    04:22

    We introduce the concept of a module as a self-contained registration unit.

    Scanning for Modules
    03:20

    A summary of all the things we've met in this section of the course.

    Summary
    07:57

    Test your comprehension by answering these questions.

    Advanced Registration Concepts Quiz
    4 questions
    +
    Implicit Relationship Types
    10 Lectures 48:51

    An overview of the things we are going to encounter in this section of the course.

    Overview
    03:03

    Configuring components that you don't need to be constructed straight away.

    Delayed Instantiation
    05:47

    What if a component wants to take responsibility for another component's lifetime?

    Controlled Instantiation
    04:15

    Auto-generated factories and why you might need them.

    Dynamic Instantiation
    05:11

    Now that we're using Func<>, what about passing in parameters?

    Parameterized Instantiation
    03:40

    What happens when you inject an IEnumerable or similar collection interface.

    Preview 05:52

    Attaching metadata to components and reading them inside these components.

    Metadata Interrogation
    09:05

    Accessing a specific service by key. Kind of like Enumeration injection, but with an IDictionary.

    Keyed Service Lookup
    05:33

    A cautionary note about getting too dependent on your DI container.

    Container Independence
    03:20

    A summary of the things we've learned in this section of the course.

    Summary
    03:05

    Test your comprehension by answering these questions.

    Implicit Relationships Types Quiz
    7 questions
    +
    Controlling Scope and Lifetime
    7 Lectures 46:19

    A taste of things to come.

    Overview
    02:31

    Scopes are used to control the lifetime of created components.

    Instance Scope
    12:20

    What happens when long-lived components accidentally (or deliberately) hold onto short-lived components?

    Captive Dependencies
    06:46

    A discussion of how objects are cleaned up when created in different scopes.

    Disposal
    04:07

    You can catch events related to lifetime changes on a component.

    Preview 09:58

    Learn about startable components.

    Running Code at Startup
    03:05

    A summary of all the things we've learned in this section of the course.

    Summary
    07:32

    Test your comprehension by answering these questions.

    Scope and Lifetime Quiz
    5 questions
    +
    Configuration
    7 Lectures 34:28

    A look at the things we'll encounter in this section of the course.

    Overview
    01:05

    What's the point of modules when we have individual components?

    Why Modules?
    09:04

    A live demo of how modules are defined and used.

    Using Modules
    07:26

    Using Microsoft Configuration Extensions, you can configure the Autofac container externally using an XML or JSON file.

    JSON/XML Configuration with Microsoft Configuration
    08:08

    A look at some of the options for configuring your components in XML/JSON files.

    Component Options
    04:27

    A look at how to configure modules in XML or JSON files.

    Configuration of Modules
    01:58

    A summary of the things we've learned in this section.

    Summary
    02:20

    Check your comprehension by answering a few questions.

    Configuration Quiz
    3 questions
    +
    Advanced Topics
    9 Lectures 01:05:55

    A look at the things we'll encounter in this section of the course.

    Overview
    01:38

    Customize the container by specifying additional classes that provide their own custom registrations. 

    Registration Sources
    15:54

    Automatically register adapters; if Foo is an adapter for IBar, ensure that c.Resolve<IList<Foo>>() gets several instances of Foo, one for each available IBar.

    Adapters
    09:07

    If Foo implements IFoo but Bar also implements IFoo and is a decorator of Bar, ensure that requests for an IFoo yield a Bar that is injected an instance of Foo.

    Decorators
    06:10

    Can two components reference each other and be resolved correctly by the container?

    Circular Dependencies
    08:13

    Metadata can be provided using Meta<T>, but thanks to Autofac's MEF integration, you can also attach it to classes using attributes, and then use other attributes to perform filtering on this metadata.

    Attribute Based Metadata
    06:04

    What happens when your component depends on too many other components? Can we avoid having a super-long constructor?

    Aggregate Services
    09:15

    Leveraging the power of Castle.DynamicProxy to do some aspect-oriented programming.

    Type Interceptors
    08:09

    A summary of all the things we've learned in this section of the course.

    Summary
    01:25

    Final set of questions to test your comprehension of advanced topics.

    Advanced Topics Quiz
    6 questions
    +
    End of Course
    3 Lectures 09:02

    A look at how to start using Autofac with ASP.NET MVC projects.

    ASP.NET MVC Integration
    07:12

    A summary of the the things we've learned in this course and where to get more info.

    Course Summary
    01:33

    Bonus Lecture: Other Courses at a Discount
    00:17
    About the Instructor
    Dmitri Nesteruk
    4.6 Average rating
    1,328 Reviews
    12,133 Students
    15 Courses
    Quant Finance • Algotrading • Software/Hardware Engineering

    Dmitri Nesteruk is a developer, speaker and podcaster. His interests lie in software development and integration practices in the areas of computation, quantitative finance and algorithmic trading. His technological interests include C#, F# and C++ programming as well high-performance computing using technologies such as CUDA. He has been a C# MVP since 2009.

    Dmitri is a graduate of University of Southampton (B.Sc. Computer Science) where he currently holds a position as a Visiting Researcher. He is also an instructor on an online intro-level Quantitative Finance course, and has also made online video courses on CUDA, MATLAB, D, the Boost libraries and other topics.