From the course: C#: Design Patterns Part 1
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Challenge: Factory Method with dependency injection - Python Tutorial
From the course: C#: Design Patterns Part 1
Challenge: Factory Method with dependency injection
(lively music) - [Instructor] For the next challenge, let's bring our example code into HPlusSports. It's possible that you need more flexibility when creating a class for a particular type from the dependency injection framework, like creating the user notifier based on application configuration. For this purpose, there's an overload method. When registering a type with the service provider, it has an option for you to provide your own factory method for a specific type. The challenge is to combine the user notifier that we created with our HPlusSports application to notify a user when an order is created for them. Use the factory method overload to return the proper user notifier. As a bonus, instead of using the compiler directives, use .NET Core's IConfiguration to be able to configure the returns type based on a value in app settings. You should be able to do all of this in the core project without making changes…
Contents
-
-
-
-
-
-
(Locked)
Factory Method pattern definition5m 3s
-
(Locked)
Factory Method pattern to choose the implementation of an action dynamically4m 26s
-
(Locked)
Factory Method design pattern for unit testing6m 5s
-
(Locked)
Challenge: Factory Method with dependency injection1m 37s
-
(Locked)
Solution: Factory Method with dependency injection3m 18s
-
(Locked)
-
-