UIController.cs 818 B

12345678910111213141516171819202122232425262728
  1. namespace XGame.Framework.UI
  2. {
  3. public abstract class UIController<TViewModel> : IUIController, IUIContextSetter, IUIViewModelSetter where TViewModel : class, IUIViewModel
  4. {
  5. private UIContext _context;
  6. public UIContext Context => _context;
  7. UIContext IUIContextSetter.Context { set => _context = value; }
  8. private IUIViewModel _viewModel;
  9. protected TViewModel VM => _viewModel as TViewModel;
  10. IUIViewModel IUIViewModelSetter.ViewModel { set => _viewModel = value; }
  11. protected abstract void OnEnable(object intent);
  12. protected abstract void OnDisable();
  13. void IUIController.Enable(object intent)
  14. {
  15. OnEnable(intent);
  16. }
  17. void IUIController.Disable()
  18. {
  19. OnDisable();
  20. }
  21. }
  22. }