What do you do when you want to create testable code or when you need to access native features? You need an interface to implement! Then you need a way to inject that implementation (dependency) to access it from your shared code (or anywhere). You will do this pretty often with mobile application development and luckily for us Xamarin.Forms has it all built in! Today' we take a look at Dependency Injection for Xamarin.Forms to create testable services and also access native features.
Full Xamarin Beginner's Playlist - https://www.youtube.com/playlist?list=PLwOF5UVsZWUiHY1CkRVjYJ6dm0iCvAlfw
👕 Buy some swag! - https://jamesmontemagno.myspreadshop.com/
Chapters:
00:00 - Intro, what is dependency injection?
03:20 - Dependency injection 101 - Create, register, resolve
13:25 - Accessing native features with dependency injection
17:30 - Wrap-up, IoC, other DI libraries
Links:
* My Coffee App GitHub - https://github.com/jamesmontemagno/mycoffeeapp?WT.mc_id=friends-0000-jamont
* Xamarin.Forms Dependency Service - https://docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/dependency-service?WT.mc_id=friends-0000-jamont
Looking to use ASP.NET Core style DI with Host Builder? This is the .NET MAUI way as well! Take a look at my blog: https://montemagno.com/add-asp-net-cores-dependency-injection-into-xamarin-apps-with-hostbuilder/
What is on my hat? It is the CLE clothing logo because I am from Cleveland! Checkout their awesome CLE merch: https://cleclothingco.myshopify.com/
What is that art on my wall? It is an original piece from the French street artist Gregos of La Butte Montmartre: https://www.instagram.com/p/BceZ1oNHiQx/
Follow:
👨💻 GitHub: https://github.com/jamesmontemagno
🦜 Twitter: https://twitter.com/jamesmontemagno
🔴 Twitch: https://twitch.tv/jamesmontemagno
📄 Website: https://www.montemagno.com
📰 Newsletter: https://newsletter.montemagno.com/
My Setup:
* Blue Spark Microphone - https://amzn.to/3qgtYkq
* Blue Pop Filter - https://amzn.to/3jEWM3r
* Rode Microphone Arm - https://amzn.to/2Z68AlE
* Sony MDR7306 Headphones - https://amzn.to/372jxta
* Stream Deck - https://amzn.to/373Uk1n
* Elgato Cam Link - https://amzn.to/3a9eGbh
* GoPro Hero - https://amzn.to/374lm90
* MX Master 2S Mouse - https://amzn.to/3d7J2gj
* Tecware Phantom Keyboard - https://amzn.to/3aUP4y9
Disclaimer: This channel, videos, and streams are created in my spare time and are a product of me... James Montemagno! They are NOT officially affiliated or endorsed by Microsoft (my employer) in any way. Opinions and views are my own.
#DependencyInjection #XamarinForms #DI #IOC