Book Image

Dependency Injection in .NET Core 2.0

By : Marino Posadas, Tadit Dash
Book Image

Dependency Injection in .NET Core 2.0

By: Marino Posadas, Tadit Dash

Overview of this book

<p><span id="description" class="sugar_field">.NET Core provides more control than ever over web application architectures. A key point of this software architecture is that it's based on the use of Dependency Injection as a way to properly implement the Dependency Inversion principle proposed in the SOLID principles established by Robert C. Martin</span>.</p> <p><span id="description" class="sugar_field">With the advent of .NET Core, things have become much simpler with Dependency Injection built into the system. This book aims to give you a profound insight into writing loosely-coupled code using the latest features available in .NET Core. It talks about constructors, parameter, setters, and interface injection, explaining in detail, with the help of examples, which type of injection to use in which situation. It will show you how to implement a class that creates other classes with associated dependencies, also called IoC containers, and then create dependencies for each MVC component of ASP.NET Core. You'll learn to distinguish between IoC containers, the use of Inversion of Control, and DI itself, since DI is just a way of implementing IoC via these containers. You'll also learn how to build dependencies for other frontend tool such as Angular. You will get to use the in-built services offered by .NET Core to create your own custom dependencies.</span></p> <p><span class="sugar_field"><span id="description" class="sugar_field">Towards the end, we'll talk about some patterns and anti-patterns for Dependency Injection along with some techniques to refactor legacy applications and inject dependencies.</span></span></p>
Table of Contents (18 chapters)
Title Page
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

About the Authors

Marino Posadas is an independent senior trainer, writer, and consultant in Microsoft Technologies and Web Standards. He is a Microsoft MVP in C#, Visual Studio, and Development Technologies; an MCT, MCPD, MCTS, MCAD, and MCSD; and he was the former Director of Development in Spain and Portugal for Solid Quality Mentors.

Marino has published 15 books and more than 500 articles on development technologies in several magazines and online publications. The topics covered in his books range from Clipper and Visual Basic 5.0/ 6.0 to C # and .NET- safe programming, programming with Silverlight 2.0 and 4.0, and Web Standards.

His latest books are Mastering C# and .NET Framework, by Packt, and The Guide to Programming in HTML5, CSS3, and JavaScript with Visual Studio. He is also a speaker at Microsoft events, having lectured in Spain, Portugal, England, the US, Costa Rica, and Mexico.

His website also contains developer's resources and videos, in English and Spanish, interviewing representatives of the Microsoft and Web Standards development world.

You can follow him on Twitter at @MarinoPosadas.

I'd like to thank Dominic Pereira, Denim Pinto, Lawrence Veigas, and Tiksha Sarang from Packt for their continuous support and confidence while writing this book. Special thanks to some professionals and technology evangelists whose work inspired different parts of this book, in particular, Mark Russinowich, Scott Hanselman, Scott Hunter (the "lesser" Scotts), and, of course, Robert Martin and Martin Fowler, pioneers in this work. Also, I would like to remember my MVP lead, Cristina González Herrero, for her continuous encouragement and help, and other people at Microsoft who have always supported my activities. My memories go here to Alfonso Rodríguez, David Carmona, David Salgado, and Leon Welicki. My appreciation also goes to my mates at Netmind for their support in this initiative from the beginning. I dedicate this book to my wife, Milagros, who makes everything possible.

 

Tadit Dash is a software engineer by profession. As a software engineer, he usually works for 8 to 9 hours daily. Besides his daily work, he contributes to both online and offline communities. He co-founded the first technical community in his state, named Microsoft Developers Community Odisha, which is devoted to spreading awareness of the newest trends in technology among developers. This community organizes events and workshops in orphanages, schools, and colleges.

He writes articles and blogs and creates demos and videos for fellow programmers. Answering questions on online forums and social channels are the activities he enjoys the most. Due to his exceptional contribution to the technical community, Microsoft has awarded him with the Microsoft Most Valuable Professional accolade since 2014. CodeProject has awarded him the CodeProject MVP accolade (the first from Odisha and three times in a row for the years 2014, 2015, and 2016). For his constant mentorship, IndiaMentor featured him as a Young Mentor on their site.

He was recognized by DZone and awarded the Most Valuable Blogger accolade. He was awarded the Star and Achiever accolade from his organization. Motivating students in his sessions is something he is popular for. He is a regular technical and motivational speaker. He has spoken at many local events organized by different communities. He was a featured speaker in DevTechDay Nepal.

I would like to dedicate this book to my grandfather, the late Mr. Ganeswar Tripathy. My grandmother Santipriya Tripathy, father, Dr. Gobinda Chandra Dash, mother, Mrs. Sasmita Tripathy, and brother, Tworit Dash who made sure that I am high on energy (with healthy food) and confidence all the time during writing. My uncles, Mr. Anil Tripathy, Mr. Aswin Tripathy, and Mr. Amiya Tripathy who always guide me to shape the approach to my new challenges. Mrs. Sujata Tripathy, who takes cares of me like my mother and Mr. Debendra Rath, my uncle, who never misses an opportunity to discuss ideas to strengthen my thoughts so that I deliver the best. My guide and mentor, Mr. Gaurav Kumar Aroraa (who is a Microsoft MVP and renowned author), encouraged me to take up the project, and constantly motivated me throughout the preparation. I am so grateful to the Packt team, especially Mr. Lawrence Veigas(Content Development Editor), and Miss. Tiksha Sarang who corrected me in every chapter. Thanks to Mr. Nirmal Hota (mobile guru of Odisha), who is like my big brother, for his consistent efforts in throwing me out of my comfort zone while patting my back. Miss. Prakreeti Prasanna, as a well wisher and best friend, always adds an x-factor to my activities. All my friends, family members, colleagues, and Google, of course, are the ingredients for the success of this book. Special thanks to my community members, Microsoft Developers Community, Odisha, for waiting to hear the surprise. Last, but not the least, Miss. Jayashree Satapathy, who, being a part of my life, has taken every care to make my writing schedule smooth.