2016-09-27 02:35:45 +02:00
|
|
|
|
using BookAStar.Helpers;
|
|
|
|
|
|
using BookAStar.Interfaces;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BookAStar.ViewModels
|
|
|
|
|
|
{
|
2016-09-29 04:54:14 +02:00
|
|
|
|
[Obsolete("Use legacy XLabs ViewModel")]
|
2016-09-27 02:35:45 +02:00
|
|
|
|
public class ViewModelBase : IModelViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
|
|
|
|
public void SetState<T>(Action<T> action) where T : class, IModelViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
action(this as T);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (object.Equals(storage, value)) return false;
|
|
|
|
|
|
|
|
|
|
|
|
storage = value;
|
|
|
|
|
|
OnPropertyChanged(propertyName);
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void OnPropertyChanged<T>(Expression<Func<T>> propertyExpression)
|
|
|
|
|
|
{
|
|
|
|
|
|
OnPropertyChanged( PropertySupport.ExtractPropertyName<T>( propertyExpression));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|