Implementing advanced dependency injection concepts

In the previous chapter, you saw how dependency injection (DI) works and how to use the constructor injection method. But, if you need to inject many instances during runtime, this method can be quite cumbersome and can make it complicated to understand and maintain your code.

Therefore, you can use a more advanced technique of DI called method injection. This allows accessing instances directly from within your code.

In the following example, you are going to add a new service for handling game invitations and update the Tic-Tac-Toe application for being able to send emails for contacting other users to join a game, while using method injection:

  1. Add a new service called GameInvitationService ...

Get Learning ASP.NET Core 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.