-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.xaml.cs
47 lines (34 loc) · 1.13 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 c971.Data;
using System.IO;
using c971.ViewModels;
using c971.Views;
namespace c971
{
public partial class App : Application
{
private static DatabaseService? _database;
public App( )
{
InitializeComponent();
// Add test data for evaluation
Task.Run( async ( ) => await App.Database.SeedDataAsync() ).Wait();
// Use AppShell as the main page for Shell-based navigation
MainPage = new AppShell();
}
// Lazy initialization of the database. Only created if the static _database is null
public static DatabaseService Database
{
get
{
if ( _database == null )
{
// Get the path to the database file
string path = Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.LocalApplicationData ), "c971.db3" );
// Create the database service
_database = new DatabaseService( path );
}
return _database;
}
}
}
}