Platform-Specific Code in .NET MAUI Using Dependency Injection

Platform-Specific Code in .NET MAUI Using Dependency Injection

Gerald Versluis

2 года назад

11,940 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@HamidZaeri
@HamidZaeri - 25.01.2024 11:02

Great video!
How to implement one similar code for like 3 platforms and a different code only for a single platform?
e.g. one specific code for Android but another same similar code for Windows, iOS and Mac? (without copying same code to each of those 3 platform folders)

Ответить
@anoushkanaidu3259
@anoushkanaidu3259 - 28.07.2023 21:16

Is this approach changed at all if I use a maui shell application? If so, how can I make adjustments to use dependency injection for writing platform-specific code?

Ответить
@codiguard
@codiguard - 10.07.2023 15:35

Very nice and clean. I am currently migrating an Xamarin app to MAUI and I felt a bit repulsed by Microsoft's docs regarding 'partial method' approach. Maybe one thing worth mention - I think that in your example `AddSingleton` instead of `AddTransient` could be used. This is very small improvement but you could save some GC time by having this :)

Ответить
@zohaibshahzad3680
@zohaibshahzad3680 - 19.05.2023 11:15

Hi
You have injected main page reference to MainPage class member if App class. How can i chain up in appshell

Ответить
@2manyChill
@2manyChill - 18.05.2023 01:50

Absolute gold man! Thank you very much

Ответить
@EroShynOObi
@EroShynOObi - 23.04.2023 02:31

.

Ответить
@hrishikeshgarud7177
@hrishikeshgarud7177 - 29.01.2023 15:33

Thanks

Ответить
@chasyadler7092
@chasyadler7092 - 26.07.2022 12:21

Hi,
Thank you!
I have created a Maui class library with a service and platform implementation,
(because I need it in multiple apps)
How do I add the class library to my Maui project to be able to add the service?

Ответить
@turelzahlane1820
@turelzahlane1820 - 08.07.2022 17:31

I have a problem when try to usebuilder.Services.AddTransient<>, when I try to do the dependency injection MAUI does not detect Platforms, so it is impossible to make the call with the interface,

Ответить
@mgbrown09
@mgbrown09 - 01.07.2022 20:56

I could use a video on how to create a cross platform control.

Ответить
@echolumaque2130
@echolumaque2130 - 09.05.2022 12:32

I replicated what you did but it throws an error saying that my class already has definition on other platform :(

Ответить
@BearishDK
@BearishDK - 05.04.2022 16:33

I keep getting issues with the same class on the different platforms.
Also tested with the code from this video, create a DeviceOrientationService on Windows platform:

The namespace 'MauiPlatformCodeDISample.Platforms' already contains a definition for 'DeviceOrientationService' MauiPlatformCodeDISample

How do you handle this?

Ответить
@kevinmarois3799
@kevinmarois3799 - 22.03.2022 01:57

Nice example. Thank you

Ответить
@chandra_arifin
@chandra_arifin - 01.01.2022 06:41

Great video. Can i deploy maui app to iphone without have Mac? (i use Windows and deploy to iphone directly)?

Ответить
@gregcyrus2739
@gregcyrus2739 - 29.12.2021 01:01

Like! Do you fiddle that out on your own... or do you get some quick briefings/ intros/ help?

Ответить
@DE-sf9sr
@DE-sf9sr - 21.12.2021 20:40

Great example! Very big fan of the cleanliness of Dependency Injection! It is so good in .Net 6, Blazor and Maui.

Ответить
@Kneebreaker
@Kneebreaker - 21.12.2021 04:54

I like this version more.

As an extension to this, I would like to figure out how to make windows/mac targets fullscreen either with some command or on launch.

Thank you for sharing so much!

Ответить
@Ihahachi
@Ihahachi - 21.12.2021 00:36

Great video thank you !

Ответить
@emmanueladebiyi2109
@emmanueladebiyi2109 - 20.12.2021 17:47

Hmm, I like this method. Nice and clean. Well done Gerald.

Ответить
@checox1909
@checox1909 - 20.12.2021 17:01

Great 🙌🏻

Ответить
@denisbrazhnichenko4651
@denisbrazhnichenko4651 - 13.12.2021 21:51

Thank you! Great examples, as always

Ответить