1 / 21

C# Dependency Injection Tutorial | C# Dependency Injection Example | C# Tutorial

This presentation on C# Dependency Injection tutorial will acquaint you with a clear understanding of the fundamentals of C# Dependency Injection.

Simplilearn
Télécharger la présentation

C# Dependency Injection Tutorial | C# Dependency Injection Example | C# Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Agenda

  2. Agenda • What is Dependency Injection? • How to Implement Dependency Injection? • Constructor Injection • Property Injection • Method Injection • Conclusion

  3. Click here to watch the video

  4. What is Dependency Injection?

  5. What is Dependency Injection? It's a software design pattern that enables for loosely coupled software. Dependency DI is a great way to reduce tight coupling between software components. DI also enables us to better manage future changes and other complexity in our software. DI's goal is to make code more manageable.

  6. How to Implement Dependency Injection?

  7. How to Implement Dependency Injection?

  8. Constructor Injection

  9. Constructor Injection The constructor injection usually has only one parameterized constructor Constructor Dependency There is no default constructor in constructor dependency. We need to pass the specified value during object creation. We can use the injection component anywhere within the class

  10. Property Injection

  11. Property Injection Property Dependency Property is typically used when we need parameter less constructor It could work without changing the object state.

  12. Method Injection

  13. Method Injection We only need to pass the dependency in the method when using method injection. Method Dependency We do not use constructor injection because it would create a dependent object every time that class is instantiated

  14. Conclusion

  15. Conclusion Dependency Injection helps in Reducing class coupling

  16. Conclusion Dependency Injection Increases the reusability of code

  17. Conclusion The Dependency Injection helps to improve code maintainability.

  18. Conclusion Dependency Injection makes it feasible to conduct unit testing.

More Related