2019-10-11 22:18:51 +00:00
|
|
|
|
using ReactiveUI;
|
|
|
|
|
using System;
|
2019-10-09 22:59:58 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Linq;
|
2019-10-11 22:18:51 +00:00
|
|
|
|
using System.Reactive.Disposables;
|
2019-10-09 22:59:58 +00:00
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2019-10-16 03:10:34 +00:00
|
|
|
|
namespace Wabbajack.Lib
|
2019-10-09 22:59:58 +00:00
|
|
|
|
{
|
2019-10-11 22:18:51 +00:00
|
|
|
|
public class ViewModel : ReactiveObject, IDisposable
|
2019-10-09 22:59:58 +00:00
|
|
|
|
{
|
2019-10-11 22:18:51 +00:00
|
|
|
|
private readonly Lazy<CompositeDisposable> _CompositeDisposable = new Lazy<CompositeDisposable>();
|
|
|
|
|
public CompositeDisposable CompositeDisposable => _CompositeDisposable.Value;
|
2019-10-09 22:59:58 +00:00
|
|
|
|
|
2019-10-11 22:18:51 +00:00
|
|
|
|
public virtual void Dispose()
|
2019-10-09 22:59:58 +00:00
|
|
|
|
{
|
2019-10-11 22:18:51 +00:00
|
|
|
|
if (_CompositeDisposable.IsValueCreated)
|
|
|
|
|
{
|
|
|
|
|
_CompositeDisposable.Value.Dispose();
|
|
|
|
|
}
|
2019-10-09 22:59:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|