Dependency Injection with Microsoft.Extensions in Xamarin.Forms

Dependency Injection with Microsoft.Extensions in Xamarin.Forms

9.669 Lượt nghe
Dependency Injection with Microsoft.Extensions in Xamarin.Forms
With the Microsoft.Extensions.DependencyInjection package setting up dependency injection becomes a breeze. Additionally, it might already be familiar to you from ASP.NET! Time to see how to add this package to a Xamarin.Forms project and make it work. While this video uses Xamarin.Forms as a sample project, this should work the same for other .NET projects. In fact, ASP.NET and .NET MAUI already have some bits on board to make the implementation even easier! 💝 Join this channel to get access to perks: https://www.youtube.com/channel/GeraldVersluis/join 🛑 Don't forget to subscribe to my channel for more amazing content: https://www.youtube.com/GeraldVersluis/?sub_confirmation=1 🐦 Follow me on Twitter: https://twitter.com/jfversluis 🤝 Join the Discord server: https://discord.gg/2cAyTGNHBD 🔗 Links Sample code repo: https://github.com/jfversluis/XFDotNetExtensionsDISample Dependency Injection for Beginners Video: https://www.youtube.com/watch?v=tTJetZj3vg0 Blog Post James Montemagno: https://montemagno.com/add-asp-net-cores-dependency-injection-into-xamarin-apps-with-hostbuilder/ ⏱ Timestamps 00:00 - Intro 00:14 - Inspect End Result 01:09 - Sample App Outline 01:40 - Microsoft.Extensions.DependencyInjection 02:36 - Sample Injected Service 03:32 - Implement Startup Class 06:05 - Implement Dependency Injection Container 07:53 - Cleaner Way To Register Dependencies 10:25 - Add ViewModel/PageModel 13:05 - Wire Up Dependency Injection In Our App 15:46 - Setup XAML Binding 17:09 - Pro-Tip: Lots of Free Extra Extensions! 18:18 - Outro 🎥 Video edited with Camtasia (ref): https://techsmith.z6rjha.net/AJoeD 🙋‍♂️ Also find my... Twitter: https://twitter.com/jfversluis Blog: https://blog.verslu.is Twitch: https://twitch.tv/jfversluis All the rest: https://jfversluis.dev #XamarinForms #dependencyinjection #microsoftextensions #di #inversionofcontrol #csharp #dotnet #dotnetmaui