wow, one of the best video on Dependency Injection, very clear. Thanks for taking time to explain.
@jfversluis3 жыл бұрын
That is such a big compliment! Thank you Paul!
@Thaizer3 жыл бұрын
Nice video. Like to see a video of DI in MAUI. Keep up the great work.
@jfversluis3 жыл бұрын
That will definitely come thanks!
@Luca_040 Жыл бұрын
Great video, refactoring our xamarin forms app to use dependency injection finally
@pakalex133 жыл бұрын
Awesome explanation about this topic, very simple and easy to understand! great video!
@jfversluis3 жыл бұрын
Thank you so much friend!
@SayyadHasan3 жыл бұрын
Again awesome tutorial, Thanks Gerald!
@jfversluis3 жыл бұрын
Thank you!
@lexusprogrammer45153 жыл бұрын
What about when you have already wired up and Binded the Context of the ViewModel directly into the View but now with “IMyService” injected into it using the Constructor, I’m trying to avoid Binding the Context from the Code behind.
@jfversluis3 жыл бұрын
I'm not entirely sure what you mean :)
@briancarroll99823 жыл бұрын
@@jfversluis I think he may be asking the same question I have. In your example, the BindingContext is being set from the code behind, but when trying to set it from within the XAML using , we get an error stating the "Type 'MainPageModel' is not usable as an object element because it is not public or does not define a public parameterless constructor or a type converter." Do you know how to get around that?
@EngDuraid3 жыл бұрын
Thank you very much for the good explanation
@jfversluis3 жыл бұрын
Glad it was helpful! Thanks for letting me know!
@revtane93 жыл бұрын
Amazing tutorial as always
@jfversluis3 жыл бұрын
Yay thanks!
@rizwansiddiqui53513 жыл бұрын
Great tutorial! I have a question, how about using this to set up a service across multiple platforms (iOS, Android). I have a interface that is implemented in platform specific code and I want to register that interface to the DI container
@jfversluis3 жыл бұрын
Good question! You would have to expose you di container in the platform project somehow and register the platform specific implementation that way :)
@amolband84032 жыл бұрын
Great Video! One questions why we have to use Microsoft.Extention when there already having default DI in Xamarin.Forms What is the differances with that Thanks
@jfversluis2 жыл бұрын
Thank you! There is no dependency injection built-in to Xamarin.Forms. The DependencyService is there but it lacks features and the performance isn’t great so you shouldn’t be using that.
@Malkaviansters2 жыл бұрын
Hey Gerald, How can you navigate around pages from ViewModels, when using this approach ?
@jfversluis2 жыл бұрын
You'll have to implement something for that yourself. FreshMvvm does it, which is open source so you might be able to borrow some inspiration from there
@mwardell182902 жыл бұрын
Okay Great Video. This is the DI Container of Choice possibly for my new project... One major question which remains; What about when you need X Platform Injection/Resolution? Into the actual Android/iOs Boundary?
@jfversluis2 жыл бұрын
If you're going to use .NET MAUI you won't even need this. Something is already built-in. This is how you could leverage DI for platform-specific code: kzbin.info/www/bejne/boPMZqGAqMajhas
@JonnyBooker2 жыл бұрын
Have implemented something similar in my project and this reaffirms what I'm doing makes sense! Quick question, do you think anything in terms of disposal of the Service Provider should be done at all? I know it implements I disposable so wasn't sure whether I should be potentially calling dispose on sleep and re-creating it on resume
@jfversluis2 жыл бұрын
I don't think you'd have to bother unless you're doing something really advanced. The Service Provider will live for your whole application lifecycle and be gone when the app gets shutdown.
@paulegan37832 жыл бұрын
Dank je wel!
@jfversluis2 жыл бұрын
Alsjeblieft!
@Varinator3 жыл бұрын
You can make it even more automated by using reflection. You can look for every Type that's name ends with "Service", then for each of the interfaces it implements you add it to the serviceProvider. You can even have a ServiceScope attribute on Interfaces to define which scope you want it to be injected as, which can also be grabbed using reflection. In the end, as long as you stick to naming convention, you can inject everything you create automatically by just writing that one dependencyInjection method and not have to worry about always adding each thing to the services as you create it.
@yuriyholembyovskyy12233 жыл бұрын
Amazing content! What I have seen from .NET MAUI samples it will use MS.Ext.DI by default or some modified version of it. Am I right? Hence it's a good idea to use this DI in your current XF apps and it will be easier to migrate to .NET MAUI.
@jfversluis3 жыл бұрын
I need to look into the details, but it should be very similar to using these extensions indeed. Maybe just even installing this literal nuget and use that :) Thanks!
@caplens_apps3 жыл бұрын
Thanks ! I am currently using the FreshMvvm Ioc in my apps, and I am hesitating to migrate as with the freshmvvm DI system, I don't need to register the viewModels before instantiating them. Any thoughts?
@jfversluis3 жыл бұрын
If you are already using FreshMvvm definitely keep using that. This is just an alternative :)
@MiguelGarcia-mb6bu3 жыл бұрын
Great tutorial! Thanks for do it, by chance You will have an sample about dependency service with xamarin forms and native using Bluetooth API?
@jfversluis3 жыл бұрын
Using it with Bluetooth is no different than using it with anything else :) you might also want to check out Shiny
@woistdasniveau82902 жыл бұрын
Could you make a video on autofac too please? All the tutorials i find are quite outdated.
@jfversluis2 жыл бұрын
Oh that might be a nice idea! Anything specific?
@TVsBen2 жыл бұрын
This was super helpful today in late 2022. Part of reducing technical debt included removing un-maintained NuGets, like TinyIoC, so I had my work cut out for me. At first I struggled to get platform-specific implementations of services injected but in the end I just added the Microsoft.Extensions libraries to all the projects in my solution and used the IServiceCollection extension methods to make it work. I add all the platform-specific service implementations in the Android and iOS projects, and it calls the extension method to add all my PCL services, and the App class's static ServiceProvider gets built from the platform code (MainActivity.OnCreate / AppDelegate.FinishedLaunching) after that. That way the ServiceContainer is in the App class, and I populate it before calling Forms.Init(). When Forms starts, all the services are already there.
@UzairAli0013 жыл бұрын
What are the benefits of using this over 3rd party libraries like AutoFac, I've already created a robust service for Autofac so should I switch to microsoft's DI?
@jfversluis3 жыл бұрын
If you already have something in place that you are happy about how it's working and performing, please keep using that!
@jmoralesv033 жыл бұрын
Great video Gerald! I think .NET MAUI will be more DI friendly, right? I remember following James' blog some time ago and it works great but I had the feeling DI was being added on top of Xamarin.Forms instead of being a first class feature, in the same way .NET Core 3.1 and .NET 5 already have it. I'm looking forward to see the DI improvements in .NET MAUI 💻📱
@jfversluis3 жыл бұрын
Thank you! .NET MAUI will definitely be more DI friendly, although that just means it already has some things on board to make it easier. It's a concept, not so much a technical implementation so it being "on top of" Xamarin.Forms, I don't know about that. In the end the concept still works the same between Forms and .NET MAUI, just the implementation is different. But anyway... Yea! It will be better with .NET MAUI :D
@mandardesai38413 жыл бұрын
Hi Gerald Thanks for the tutorial Will you make a video on complete xamarin app development like DevOps means how we use azure, jira, Github, visual studio, app center some analytic tools and other tools in smart way. inshort all modern tools that use in xamarin application development. i hope you understand what i mean. Thanks again.
@philippedoumet60733 жыл бұрын
Hello Gerald, can you please make a video about integrating stripe payments in xamarin forms?🙏🏻🙏🏻
@philippedoumet60733 жыл бұрын
And I have an error that is coming when i upload a picture in firebase, can I send it to you?
@jfversluis3 жыл бұрын
You can post it in the Discord server so other people might be able to help as well :)
@checox19093 жыл бұрын
Great video man, can you do something about how to use bluetooth with dependency services to implement our own methods without depending on any 3rd party library... I'm trying to do something like that in a project but could be cool if there are any docs of someone implementing that.
@jfversluis3 жыл бұрын
Why would you want to do that? I guess you could just take a look at an open-source library that does this and implement your own from that :)
@checox19093 жыл бұрын
@@jfversluis Hehehehe, Yes that's exactly what I'm doing, I just wanted to know if you have a better way to do it, I'm using plugin.ble, but that library has poor documentation, but I'm using it to implement it on my own
@thatrandomguybob48003 жыл бұрын
I am also trying to get bluetooth (BLE) integrated into my app, using Shiny 2.0. I am having a heck of a time as I am not a seasoned developer and I am new to DI.