.NET WinForms应用程序的MVC / MVP框架

时间:2021-10-24 17:00:25

Does anybody know a useable MVC/MVP framework for enterprise WinForms applications?

有没有人知道企业WinForms应用程序的可用MVC / MVP框架?

Before there was User Interface Process Application Block for .NET. But it is not longer under development since Windows Workflow Foundation has been released (which also will be completely rewritten with .NET 4.0).

之前有.NET用户界面进程应用程序块。但是,自Windows Workflow Foundation发布以来,它已不再处于开发阶段(也将完全用.NET 4.0重写)。

Maybe i am not up-to-date, but i seems to me like there is a gap at the moment.

也许我不是最新的,但我觉得我现在有一个差距。

10 个解决方案

#1


Microsoft has the Composite Application Block (CAB) for use with WinForms applications. While not technically an MVC/MVP implementation, it does provide nice separation between UI code and non-UI code: http://msdn.microsoft.com/en-us/library/aa480450.aspx

Microsoft具有用于WinForms应用程序的复合应用程序块(CAB)。虽然从技术上讲不是MVC / MVP实现,但它确实提供了UI代码和非UI代码之间的良好分离:http://msdn.microsoft.com/en-us/library/aa480450.aspx

It is also fairly popular to just do it yourself without using any frameworks as long as you are comfortable with the relevant patterns. Jeremy Miller has an excellent series of articles on some best practices when taking this approach:

只要您对相关模式感到满意,在不使用任何框架的情况下自己动手也很受欢迎。在采用这种方法时,杰里米·米勒(Jeremy Miller)有一系列关于一些最佳实践的优秀文章:

Build your own CAB Part #1 - The Preamble

建立自己的CAB第1部分 - 序言

Build your own CAB Part #2 - The Humble Dialog Box

建立自己的CAB Part#2 - The Humble Dialog Box

Build your own CAB Part #3 - The Supervising Controller Pattern

构建自己的CAB第3部分 - 监督控制器模式

Build your own CAB Part #4 - The Passive View

建立自己的CAB第4部分 - 被动视图

Build your own CAB Part #5 - The Presentation Model

构建自己的CAB第5部分 - 演示模型

Build your own CAB Part #6 - View to Presenter Communication

构建自己的CAB第6部分 - 查看演示者通信

Build your own CAB - Answering some questions

建立自己的CAB - 回答一些问题

Build your own CAB Part #7 - Whats the Model?

建立自己的CAB第7部分 - 什么是模型?

Build your own CAB Part #8 - Assigning Responsibilities in a Model View Presenter Architecture

构建您自己的CAB第8部分 - 在模型视图Presenter体系结构中分配职责

Build your own CAB Part #9 - Domain Centric Validation with the Notification Pattern

使用通知模式构建您自己的CAB第9部分 - 以域为中心的验证

Build your own CAB Part #10 - Unit Testing the UI with NUnitForms

构建自己的CAB Part#10 - 单元使用NUnitForms测试UI

Build your own CAB Part #11 - Event Aggregator

构建自己的CAB Part#11 - Event Aggregator

Build your own CAB Part #12 - Rein in runaway events with the "Latch"

建立自己的CAB第12部分 - 使用“Latch”加速失控事件

Build your own CAB Part #13 - Embedded Controllers with a Dash of DSL

构建您自己的CAB Part#13 - 带有Dash of DSL的嵌入式控制器

#2


Have you tried MVC#? I started using it a while back, but the project fell by the wayside, so I can't vouch for it to much - sorry!

你试过MVC#?我开始使用它一段时间,但项目落在了路边,所以我不能保证它 - 很抱歉!

EDIT: I just found this article which looks pretty good too.

编辑:我刚刚发现这篇文章看起来也很不错。

#3


We use the Smart Client Software Factory from MS. It provides IDE integration, full MVC support and once you get over the concepts behind it is a very competent implementation. You can acquire it from: http://msdn.microsoft.com/en-us/library/aa480482.aspx

我们使用MS的智能客户端软件工厂。它提供IDE集成,完整的MVC支持,一旦你克服它背后的概念是一个非常称职的实现。您可以从以下网站获取它:http://msdn.microsoft.com/en-us/library/aa480482.aspx

#4


Smart Client Software Factory?

智能客户端软件工厂?

#5


I've always rolled my own - it's not really difficult and the more I am in 'control' of my codebase the better I feel.

我总是自己动手 - 这并不是很困难,我对代码库的“控制”越多,我感觉越好。

I just wonder how an MVC framework would fit in with, say, CastleWindsor or the like?

我只是想知道一个MVC框架如何适应,比如CastleWindsor之类的东西?

This probably isn't the most helpful of answers but just wondering if you have already considered this option!

这可能不是最有帮助的答案,但只是想知道你是否已经考虑过这个选项!

#6


I didn't like Prism, CAB or SmartClient for being too complex and ended up rolling out my own implementations, in the end.

我不喜欢Prism,CAB或SmartClient因为过于复杂而最终推出了我自己的实现。

As time goes, some common patterns are emerging. These are get reused from an application to an application. Here is an example: DDD and Rule driven UI Validation in Windows.Forms with MVC.

随着时间的推移,一些常见的模式正在出现。这些可以从应用程序重用到应用程序。下面是一个示例:带有MVC的Windows.Forms中的DDD和规则驱动的UI验证。

#7


I'm plugging my own framework : TrueView for .NET. It's based on DDD and the Naked Objects pattern.

我正在插入我自己的框架:TrueView for .NET。它基于DDD和Naked Objects模式。

At the very least, using it to create quick prototypes is a great way to get decent feedback from your business users.

至少,使用它来创建快速原型是从业务用户那里获得良好反馈的好方法。

#8


All these standard frameworks are not suitable for large complex application developments and they assume that the displays will be static. I have developed my own as well due to the common requirement that the screen controls have to be dynamic, even the MVC/MVP patterns assume that the display will be static so when the fields diplayed in a control depend on what role a user has the MVC/MVP patterns are not suitable. I have developed a tool where you can build the screens from loading up the business objects and their properties into a database then the user just selects the objects and object properties she wants to display, a control can be made up of any number of control groups, each control group can contain any business object property, the business objects are generated from views by my Linq ORM. A control will therefore only display the fields of the control groups that a user has access to. You could also use Aspect orientated programming to provide the gule for the MVC pattern but when the displays have to be dynamic based on the role this overhead would probably add a little to much complexity and performance cost.

所有这些标准框架都不适合大型复杂的应用程序开发,并且他们假设显示器是静态的。我也开发了自己的,因为屏幕控件必须是动态的共同要求,即使MVC / MVP模式假设显示器是静态的,所以当控件中的字段显示取决于用户具有什么角色时MVC / MVP模式不适合。我开发了一个工具,您可以构建屏幕,将业务对象及其属性加载到数据库中,然后用户只需选择要显示的对象和对象属性,控件可以由任意数量的控件组组成,每个控制组都可以包含任何业务对象属性,业务对象是由我的Linq ORM从视图生成的。因此,控件仅显示用户有权访问的控制组的字段。您还可以使用面向方面的编程来为MVC模式提供gule,但是当显示必须是基于角色的动态时,这种开销可能会增加一些复杂性和性能成本。

#9


As well as TrueView, there's also Naked Objects for .NET. This supports client/server mode and a web viewer (based on a Java equivalent viewer) is currently being ported.

和TrueView一样,还有Naked Objects for .NET。这支持客户端/服务器模式,并且当前正在移植Web查看器(基于Java等效查看器)。

As for which properties/actions are available for a given user/role, this is done dynamically in Naked Objects. There are three sorts of business rules preconditions that are supported: 1. is the member visible? 2. is the member usable? 3. is the change to the member (new property value or action parameter) valid? Or, more pithily: can you see it? can you use it? can you do it? The Naked Objects programming model lets these rules be specified both declaratively and imperatively.

至于给定用户/角色可用的属性/操作,这是在Naked Objects中动态完成的。支持的业务规则有三种前提条件:1。成员是否可见? 2.会员可以使用吗? 3.对成员的更改(新属性值或操作参数)是否有效?或者,更简洁:你能看到吗?你能用吗?你可以做到吗? Naked Objects编程模型允许以声明方式和命令方式指定这些规则。

Even if you end up wrapping your domain model in your own UI layer, I recommend you take a look at NO.

即使您最终将域模型包装在自己的UI层中,我建议您看一下NO。

Cheers

Dan Haywood

author: "Domain Driven Design using Naked Objects", pragprog.com

作者:“使用Naked Objects的域驱动设计”,pragprog.com

#10


I've used with success the following open source project to implement the MVP pattern in ASP.NET + WinForms + C#:

我已成功使用以下开源项目来实现ASP.NET + WinForms + C#中的MVP模式:

  • Castle Project.

Take a look at my blog post which shows a complete ASP.NET Web Application sample:

看看我的博客文章,其中显示了一个完整的ASP.NET Web应用程序示例:

Model View Presenter pattern with Castle in ASP.NET

模型视图Presenter模式与城堡在ASP.NET中

#1


Microsoft has the Composite Application Block (CAB) for use with WinForms applications. While not technically an MVC/MVP implementation, it does provide nice separation between UI code and non-UI code: http://msdn.microsoft.com/en-us/library/aa480450.aspx

Microsoft具有用于WinForms应用程序的复合应用程序块(CAB)。虽然从技术上讲不是MVC / MVP实现,但它确实提供了UI代码和非UI代码之间的良好分离:http://msdn.microsoft.com/en-us/library/aa480450.aspx

It is also fairly popular to just do it yourself without using any frameworks as long as you are comfortable with the relevant patterns. Jeremy Miller has an excellent series of articles on some best practices when taking this approach:

只要您对相关模式感到满意,在不使用任何框架的情况下自己动手也很受欢迎。在采用这种方法时,杰里米·米勒(Jeremy Miller)有一系列关于一些最佳实践的优秀文章:

Build your own CAB Part #1 - The Preamble

建立自己的CAB第1部分 - 序言

Build your own CAB Part #2 - The Humble Dialog Box

建立自己的CAB Part#2 - The Humble Dialog Box

Build your own CAB Part #3 - The Supervising Controller Pattern

构建自己的CAB第3部分 - 监督控制器模式

Build your own CAB Part #4 - The Passive View

建立自己的CAB第4部分 - 被动视图

Build your own CAB Part #5 - The Presentation Model

构建自己的CAB第5部分 - 演示模型

Build your own CAB Part #6 - View to Presenter Communication

构建自己的CAB第6部分 - 查看演示者通信

Build your own CAB - Answering some questions

建立自己的CAB - 回答一些问题

Build your own CAB Part #7 - Whats the Model?

建立自己的CAB第7部分 - 什么是模型?

Build your own CAB Part #8 - Assigning Responsibilities in a Model View Presenter Architecture

构建您自己的CAB第8部分 - 在模型视图Presenter体系结构中分配职责

Build your own CAB Part #9 - Domain Centric Validation with the Notification Pattern

使用通知模式构建您自己的CAB第9部分 - 以域为中心的验证

Build your own CAB Part #10 - Unit Testing the UI with NUnitForms

构建自己的CAB Part#10 - 单元使用NUnitForms测试UI

Build your own CAB Part #11 - Event Aggregator

构建自己的CAB Part#11 - Event Aggregator

Build your own CAB Part #12 - Rein in runaway events with the "Latch"

建立自己的CAB第12部分 - 使用“Latch”加速失控事件

Build your own CAB Part #13 - Embedded Controllers with a Dash of DSL

构建您自己的CAB Part#13 - 带有Dash of DSL的嵌入式控制器

#2


Have you tried MVC#? I started using it a while back, but the project fell by the wayside, so I can't vouch for it to much - sorry!

你试过MVC#?我开始使用它一段时间,但项目落在了路边,所以我不能保证它 - 很抱歉!

EDIT: I just found this article which looks pretty good too.

编辑:我刚刚发现这篇文章看起来也很不错。

#3


We use the Smart Client Software Factory from MS. It provides IDE integration, full MVC support and once you get over the concepts behind it is a very competent implementation. You can acquire it from: http://msdn.microsoft.com/en-us/library/aa480482.aspx

我们使用MS的智能客户端软件工厂。它提供IDE集成,完整的MVC支持,一旦你克服它背后的概念是一个非常称职的实现。您可以从以下网站获取它:http://msdn.microsoft.com/en-us/library/aa480482.aspx

#4


Smart Client Software Factory?

智能客户端软件工厂?

#5


I've always rolled my own - it's not really difficult and the more I am in 'control' of my codebase the better I feel.

我总是自己动手 - 这并不是很困难,我对代码库的“控制”越多,我感觉越好。

I just wonder how an MVC framework would fit in with, say, CastleWindsor or the like?

我只是想知道一个MVC框架如何适应,比如CastleWindsor之类的东西?

This probably isn't the most helpful of answers but just wondering if you have already considered this option!

这可能不是最有帮助的答案,但只是想知道你是否已经考虑过这个选项!

#6


I didn't like Prism, CAB or SmartClient for being too complex and ended up rolling out my own implementations, in the end.

我不喜欢Prism,CAB或SmartClient因为过于复杂而最终推出了我自己的实现。

As time goes, some common patterns are emerging. These are get reused from an application to an application. Here is an example: DDD and Rule driven UI Validation in Windows.Forms with MVC.

随着时间的推移,一些常见的模式正在出现。这些可以从应用程序重用到应用程序。下面是一个示例:带有MVC的Windows.Forms中的DDD和规则驱动的UI验证。

#7


I'm plugging my own framework : TrueView for .NET. It's based on DDD and the Naked Objects pattern.

我正在插入我自己的框架:TrueView for .NET。它基于DDD和Naked Objects模式。

At the very least, using it to create quick prototypes is a great way to get decent feedback from your business users.

至少,使用它来创建快速原型是从业务用户那里获得良好反馈的好方法。

#8


All these standard frameworks are not suitable for large complex application developments and they assume that the displays will be static. I have developed my own as well due to the common requirement that the screen controls have to be dynamic, even the MVC/MVP patterns assume that the display will be static so when the fields diplayed in a control depend on what role a user has the MVC/MVP patterns are not suitable. I have developed a tool where you can build the screens from loading up the business objects and their properties into a database then the user just selects the objects and object properties she wants to display, a control can be made up of any number of control groups, each control group can contain any business object property, the business objects are generated from views by my Linq ORM. A control will therefore only display the fields of the control groups that a user has access to. You could also use Aspect orientated programming to provide the gule for the MVC pattern but when the displays have to be dynamic based on the role this overhead would probably add a little to much complexity and performance cost.

所有这些标准框架都不适合大型复杂的应用程序开发,并且他们假设显示器是静态的。我也开发了自己的,因为屏幕控件必须是动态的共同要求,即使MVC / MVP模式假设显示器是静态的,所以当控件中的字段显示取决于用户具有什么角色时MVC / MVP模式不适合。我开发了一个工具,您可以构建屏幕,将业务对象及其属性加载到数据库中,然后用户只需选择要显示的对象和对象属性,控件可以由任意数量的控件组组成,每个控制组都可以包含任何业务对象属性,业务对象是由我的Linq ORM从视图生成的。因此,控件仅显示用户有权访问的控制组的字段。您还可以使用面向方面的编程来为MVC模式提供gule,但是当显示必须是基于角色的动态时,这种开销可能会增加一些复杂性和性能成本。

#9


As well as TrueView, there's also Naked Objects for .NET. This supports client/server mode and a web viewer (based on a Java equivalent viewer) is currently being ported.

和TrueView一样,还有Naked Objects for .NET。这支持客户端/服务器模式,并且当前正在移植Web查看器(基于Java等效查看器)。

As for which properties/actions are available for a given user/role, this is done dynamically in Naked Objects. There are three sorts of business rules preconditions that are supported: 1. is the member visible? 2. is the member usable? 3. is the change to the member (new property value or action parameter) valid? Or, more pithily: can you see it? can you use it? can you do it? The Naked Objects programming model lets these rules be specified both declaratively and imperatively.

至于给定用户/角色可用的属性/操作,这是在Naked Objects中动态完成的。支持的业务规则有三种前提条件:1。成员是否可见? 2.会员可以使用吗? 3.对成员的更改(新属性值或操作参数)是否有效?或者,更简洁:你能看到吗?你能用吗?你可以做到吗? Naked Objects编程模型允许以声明方式和命令方式指定这些规则。

Even if you end up wrapping your domain model in your own UI layer, I recommend you take a look at NO.

即使您最终将域模型包装在自己的UI层中,我建议您看一下NO。

Cheers

Dan Haywood

author: "Domain Driven Design using Naked Objects", pragprog.com

作者:“使用Naked Objects的域驱动设计”,pragprog.com

#10


I've used with success the following open source project to implement the MVP pattern in ASP.NET + WinForms + C#:

我已成功使用以下开源项目来实现ASP.NET + WinForms + C#中的MVP模式:

  • Castle Project.

Take a look at my blog post which shows a complete ASP.NET Web Application sample:

看看我的博客文章,其中显示了一个完整的ASP.NET Web应用程序示例:

Model View Presenter pattern with Castle in ASP.NET

模型视图Presenter模式与城堡在ASP.NET中