WinForms 应用程序中的控制器/静态状态类 - 放在哪里? [英] Controller/Static State Class in WinForms Application - Where to put?

查看:25
本文介绍了WinForms 应用程序中的控制器/静态状态类 - 放在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 WinForms 应用程序并且想要一个MVC 类型"的设计.其实更像是MVP或者MVVM.

I'm writing a WinForms application and want to have an "MVC-Type" Design. Actually it's more MVP or MVVM,.

我们的计划是拥有一个中央控制器来完成所有实际工作,以便表单只呈现 ViewModel 并处理用户输入,但实际执行某些操作的一切都通过控制器.

The plan is to have a Central Controller which does all the actual work, so that the Forms just render out ViewModels and handle user input, but everything that actually does something goes through the Controller.

我只是想知道这是否是一个好主意,以及将控制器放在哪里?当前的想法是有一个在 Program.cs 中初始化的静态类(在一些依赖项中发送,如 IMyDatabaseRepository),以便它只是一个控制器,在用户界面和模型之间委托工作.

I just wonder if this is a good idea, and where to put the Controller? The current idea is to have a static class which is initialized in Program.cs (Sending in some Dependencies like IMyDatabaseRepository) so that it just stays a controller that delegates work between User Interface and Model.

您可能会猜到,我来自 Web 背景,对 WinForms 架构几乎没有经验.以前,我的 MainForm 是 Controller 类,持有所有状态变量,这显然意味着我的 MainForm 是我的应用程序,而不仅仅是用户界面的一部分.

As you might guess, I come from a Web Background and have little experience with WinForms architecture. Previously, my MainForm was the Controller class, holding all the State Variables, which obviously means that my MainForm is my application rather than just a part of the User Interface.

推荐答案

迈克尔的好问题!

这里有一些链接:

希望这些能帮助您正确构建您的项目!

Hope these help you to structure your project properly!

这篇关于WinForms 应用程序中的控制器/静态状态类 - 放在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆