Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem committed Mar 6, 2024
1 parent b40ca6b commit d2edf23
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
15 changes: 12 additions & 3 deletions Masa.Blazor.Pro.Components/Data/ProDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@ public class ProDatabase
// enable multi-threaded database access
SQLiteOpenFlags.SharedCache;

// public static string DatabasePath =>
// Path.Combine(FileSystem.AppDataDirectory, DatabaseFilename);
public ProDatabase()
{
DatabasePath = DatabaseFilename;
}

public ProDatabase(string dir)
{
DatabasePath = Path.Combine(dir, DatabaseFilename);
}

public string DatabasePath { get; private set; }

private SQLiteAsyncConnection? Database { get; set; }

Expand All @@ -30,7 +39,7 @@ async Task InitAsync()
return;
}

Database = new SQLiteAsyncConnection(DatabaseFilename, Flags);
Database = new SQLiteAsyncConnection(DatabasePath, Flags);
await Database.CreateTableAsync<TodoTask>();
await Database.CreateTableAsync<TodoTag>();
}
Expand Down
6 changes: 4 additions & 2 deletions ProApp/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Masa.Blazor.Pro.Components;
using Microsoft.Extensions.Logging;

namespace ProApp
{
Expand All @@ -15,7 +16,8 @@ public static MauiApp CreateMauiApp()
});

builder.Services.AddMauiBlazorWebView();
builder.Services.AddMasaBlazor();
builder.Services.AddMasaBlazorPro();
builder.Services.AddSingleton(_ = new ProDatabase(FileSystem.AppDataDirectory));

builder.Services.AddLogging(logging =>
{
Expand Down
1 change: 1 addition & 0 deletions ProApp/ProApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.8" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit d2edf23

Please sign in to comment.