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-05-02 21:44:13 +02:00
|
|
|
public sealed class Workspace(IServiceScope scope) : IDisposable
|
2024-02-16 02:23:58 +01:00
|
|
|
{
|
2024-02-21 02:17:33 +01:00
|
|
|
private bool _disposedValue;
|
2024-05-02 21:44:13 +02:00
|
|
|
private IServiceScope? _scope = scope;
|
2024-02-21 02:17:33 +01:00
|
|
|
|
|
|
|
|
public string Name { get; set; } = default!;
|
|
|
|
|
|
|
|
|
|
public LocalWorkspaceOptions Options { get; set; } = default!;
|
|
|
|
|
|
2024-05-02 21:44:13 +02:00
|
|
|
public IServiceProvider Services { get; } = scope.ServiceProvider;
|
2024-02-21 02:17:33 +01:00
|
|
|
|
|
|
|
|
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-02-16 02:23:58 +01:00
|
|
|
}
|