namespace IFramework.MVVM { /// /// MVVM 组结构 /// public class MVVMGroup : Unit { private ViewModel _viewModel; private View _view; private IModel _model; private string _name; /// /// 组名 /// public string name { get { return _name; } } /// /// 界面 /// public View view { get { return _view; } } /// /// 数据 /// public IModel model { get { return _model; } } /// /// VM /// public ViewModel viewModel { get { return _viewModel; } } /// /// Ctor /// /// /// /// /// public MVVMGroup(string name, View view, ViewModel viewModel, IModel model) { this._name = name; this._view = view; this._model = model; this._viewModel = viewModel; this._viewModel.group = this; (_viewModel as IViewModel).Initialize(); this._view.context = _viewModel; (_viewModel as IViewModel).SyncModelValue(); } /// /// 发布model数据发生变化 /// public void PublishModelDirty() { if (viewModel != null) { (_viewModel as IViewModel).SyncModelValue(); } } /// /// 释放时 /// public override void Dispose() { if (disposed) return; base.Dispose(); if (_view != null) { _view.Dispose(); } if (_viewModel != null) { _viewModel.Dispose(); } } /// /// 释放时 /// protected override void OnDispose() { } } }