forked from Vivelin/CatAlarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.xaml.cs
47 lines (36 loc) · 1.07 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using MauiCatAlarm.Services;
using Microsoft.Extensions.Logging;
using System.Diagnostics;
namespace MauiCatAlarm;
public partial class App : Application
{
private readonly IServiceScope _serviceScope;
private bool _isAlarmActive;
public App(AlarmService alarmService, IServiceProvider serviceProvider, ILogger<App> logger)
{
_serviceScope = serviceProvider.CreateScope();
InitializeComponent();
//Debug.WriteLine("App start");
alarmService.EnsureAlarmIsSetIfEnabled();
MainPage = new AppShell();
}
public static new App Current => (App)Application.Current!;
public IServiceProvider ServiceProvider => _serviceScope.ServiceProvider;
public bool IsAlarmActive
{
get => _isAlarmActive;
set
{
if (_isAlarmActive != value)
{
_isAlarmActive = value;
OnPropertyChanged(nameof(IsAlarmActive));
}
}
}
protected override void CleanUp()
{
_serviceScope.Dispose();
base.CleanUp();
}
}