Use injetion wher epossible for services

pull/42/head
James Montemagno 2022-02-25 12:21:10 -08:00
parent a57b87eeb2
commit a006599675
2 changed files with 6 additions and 2 deletions

View File

@ -7,7 +7,7 @@ public partial class Player : ContentView
public Player()
{
InitializeComponent();
this.playerService = ServicesProvider.GetService<PlayerService>();
this.playerService = this.Handler.MauiContext.Services.GetService<PlayerService>();
this.IsVisible = false;
}

View File

@ -2,11 +2,15 @@
public class WifiOptionsService
{
#if __MACCATALYST__
Platforms.MacCatalyst.ConnectivityService connectivity;
public WifiOptionsService(Platforms.MacCatalyst.ConnectivityService connectivity) => this.connectivity = connectivity;
#endif
public async Task<bool> HasWifiOrCanPlayWithOutWifiAsync()
{
#if __MACCATALYST__
var connectivity = ServicesProvider.GetService<Platforms.MacCatalyst.ConnectivityService>();
return await connectivity.IsConnected();
#else
if (Config.Desktop)