2021-12-26 21:56:44 +00:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using ReactiveUI;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Reactive.Disposables;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
2021-12-29 17:26:12 +00:00
|
|
|
|
using Wabbajack.Models;
|
2021-12-26 21:56:44 +00:00
|
|
|
|
|
2021-12-30 00:15:37 +00:00
|
|
|
|
namespace Wabbajack
|
2021-12-26 21:56:44 +00:00
|
|
|
|
{
|
2021-12-29 17:26:12 +00:00
|
|
|
|
public class ViewModel : ReactiveObject, IDisposable, IActivatableViewModel
|
2021-12-26 21:56:44 +00:00
|
|
|
|
{
|
2021-12-29 17:26:12 +00:00
|
|
|
|
private readonly Lazy<CompositeDisposable> _compositeDisposable = new();
|
2021-12-26 21:56:44 +00:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public CompositeDisposable CompositeDisposable => _compositeDisposable.Value;
|
|
|
|
|
|
2021-12-29 17:26:12 +00:00
|
|
|
|
[JsonIgnore] public LoadingLock LoadingLock { get; } = new();
|
|
|
|
|
|
2021-12-26 21:56:44 +00:00
|
|
|
|
public virtual void Dispose()
|
|
|
|
|
{
|
|
|
|
|
if (_compositeDisposable.IsValueCreated)
|
|
|
|
|
{
|
|
|
|
|
_compositeDisposable.Value.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void RaiseAndSetIfChanged<T>(
|
|
|
|
|
ref T item,
|
|
|
|
|
T newItem,
|
|
|
|
|
[CallerMemberName] string? propertyName = null)
|
|
|
|
|
{
|
|
|
|
|
if (EqualityComparer<T>.Default.Equals(item, newItem)) return;
|
|
|
|
|
item = newItem;
|
|
|
|
|
this.RaisePropertyChanged(propertyName);
|
|
|
|
|
}
|
2021-12-29 17:26:12 +00:00
|
|
|
|
|
|
|
|
|
public ViewModelActivator Activator { get; } = new();
|
2021-12-26 21:56:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|