なろうブックマーク分析用ツールのPrism+WinUI3サンプル実装
修訂. | 91b05482e5b7288185c0f453ccfc74c20099b04b |
---|---|
大小 | 2,138 bytes |
時間 | 2023-09-30 19:37:53 |
作者 | yoshy |
Log Message | [MOD] プロジェクト間の依存関係、外部パッケージへの依存関係の修正
|
using NLog;
using Prism.Navigation;
using Prism.Regions;
using Reactive.Bindings;
using Reactive.Bindings.Extensions;
using System.Reactive.Disposables;
using TestNarou3.Adaptor.Boundary.Controller;
using TestNarou3.Adaptor.Boundary.Gateway.ViewModel;
using TestNarou3.Infra.Boundary.Resource;
using TestNarou3.UseCase.Request;
namespace TestNarou3.Adaptor.Gateway.ViewModel
{
internal class MainWindowViewModel : IMainWindowViewModel, IDestructible, IDisposable
{
private static readonly ILogger logger = LogManager.GetCurrentClassLogger();
public ReactiveProperty<string> Title { get; }
private readonly IAppWindowController wc;
private readonly IRegionManager rm;
private readonly CompositeDisposable disposables = new();
private bool disposedValue;
public MainWindowViewModel(
IAppCaptionFormatter caption,
IAppWindowController wc,
IRegionManager rm)
{
this.wc = wc;
this.rm = rm;
this.Title = new ReactiveProperty<string>(caption.GetDefaultCaption()).AddTo(disposables);
}
public void OnClosing()
{
_ = this.wc.Execute(new NarouLogoutRequest());
_ = this.wc.Execute(new AppConfigSaveRequest());
this.Dispose();
}
#region IDestructible, IDisposable
public void Destroy()
{
this.Dispose();
}
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
this.disposables.Dispose();
logger.Trace("MainWindowViewModel disposed.");
foreach (IRegion region in rm.Regions)
{
region.RemoveAll();
}
}
disposedValue = true;
}
}
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
#endregion
}
}