using IFramework.Message;
namespace IFramework.MVVM
{
internal interface IViewModel
{
void Initialize();
void SyncModelValue();
void Listen(IEventArgs message);
}
///
/// VM
///
public abstract class ViewModel : ObservableObject, IViewModel
{
internal MVVMGroup group { get; set; }
///
/// 数据
///
protected IModel model { get { return group.model; } }
void IViewModel.SyncModelValue()
{
SyncModelValue();
}
void IViewModel.Initialize()
{
Initialize();
}
void IViewModel.Listen(IEventArgs message)
{
Listen(message);
}
///
/// 初始化
///
protected abstract void Initialize();
///
/// 同步model数据
///
protected abstract void SyncModelValue();
///
/// 来自于view的消息
///
///
protected abstract void Listen(IEventArgs message);
///
/// 释放时
///
protected override void OnDispose() { }
}
///
/// 方便书写
///
public abstract class ViewModel : ViewModel where T : IModel
{
///
/// 方便书写
///
protected T Tmodel { get { return (T)group.model; } }
}
}