2024-02-21 02:17:33 +01:00
|
|
|
using InkForge.Desktop.Data.Options;
|
|
|
|
|
|
2024-02-16 02:23:58 +01:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
namespace InkForge.Desktop.Models;
|
|
|
|
|
|
2024-02-21 02:17:33 +01:00
|
|
|
public sealed class Workspace : IDisposable
|
2024-02-16 02:23:58 +01:00
|
|
|
{
|
2024-02-21 02:17:33 +01:00
|
|
|
private bool _disposedValue;
|
|
|
|
|
private IServiceScope? _scope;
|
|
|
|
|
|
|
|
|
|
public string Name { get; set; } = default!;
|
|
|
|
|
|
|
|
|
|
public LocalWorkspaceOptions Options { get; set; } = default!;
|
|
|
|
|
|
|
|
|
|
public IServiceProvider Services => _scope!.ServiceProvider;
|
|
|
|
|
|
|
|
|
|
public Workspace(IServiceScope scope)
|
|
|
|
|
{
|
|
|
|
|
_scope = scope;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
if (!_disposedValue)
|
|
|
|
|
{
|
2024-03-17 22:27:01 +01:00
|
|
|
if (_scope is { })
|
|
|
|
|
{
|
|
|
|
|
_scope.Dispose();
|
|
|
|
|
_scope = null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-21 02:17:33 +01:00
|
|
|
_disposedValue = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-05 12:31:34 +02:00
|
|
|
|
|
|
|
|
// private async Task LoadNotes()
|
|
|
|
|
// {
|
|
|
|
|
// await using var dbContext = await _dbContextFactory.CreateDbContextAsync().ConfigureAwait(false);
|
|
|
|
|
// await foreach (var asdf in dbContext.Notes.AsAsyncEnumerable().ConfigureAwait(false))
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// _ = (await dbContext.Notes.ToListAsync().ConfigureAwait(false));
|
|
|
|
|
// }
|
2024-02-16 02:23:58 +01:00
|
|
|
}
|