插件架构的ASP.NET MVC [英] Plug-in architecture for ASP.NET MVC

查看:103
本文介绍了插件架构的ASP.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经花了一些时间看菲尔哈克的文章分组控制器非常有趣的东西。

I've been spending some time looking at Phil Haack's article on Grouping Controllers very interesting stuff.

目前,我试图找出是否有可能使用同样的想法来创建一个项目我工作的一个插件/模块化架构。

At the moment I'm trying to figure out if it would be possible to use the same ideas to create a plug-in/modular architecture for a project I'm working on.

所以我的问题是:是否有可能有地区在多个项目菲尔的文章分割

So my question is: Is it possible to have the Areas in Phil's article split across multiple projects?

我可以看到名称空间将工作自己了,但我很担心在正确的地方结束了意见。有什么事情可以生成规则进行排序呢?

I can see that the name spaces will work themselves out, but I'm concerned about the views ending up in the right place. Is it something that can be sorted out with build rules?

假设上面的是可能在一个单一的解决方案多个项目,有没有人有关于使其能够与一个独立的解决方案和编码到predefined设置接口的最佳方法什么想法?从一个区域移动到插件。

Assuming that the above is possible with multiple projects in a single solution, does anyone have any ideas about the best way to make it possible with a separate solution and coding to a predefined set of interfaces? Moving from an Area to a plug-in.

我有一个插件架构,但不是群众的一些经验,以便在这一领域的任何指导将是有益的。

I have some experiences with plug-in architecture but not masses so any guidance in this area would be useful.

推荐答案

我做了概念证明几个星期前,我把组件的完整堆栈:一个模型类,控制类及其相关的意见为DLL ,加/调整<一href=\"http://stackoverflow.com/questions/236972/using-virtualpathprovider-to-load-aspnet-mvc-views-from-dlls\">one用于检索的意见,使他们会处理那些在DLL 上的VirtualPathProvider类的例子适当。

I did a proof of concept a few weeks ago where I put a complete stack of components: a model class, a controller class and their associated views into a DLL, added/tweaked one of the examples of the VirtualPathProvider classes that retrieve the views so they'd address those in the DLL appropriately.

在最后,我只是放弃了DLL到一个适当配置MVC应用程序和它的工作就像如果它已经从一开始的MVC应用程序的一部分。我把它远一点,并与这些小微型MVC插件就好了5工作。很显然,你身边有洗牌当这一切看你的引用和配置的依赖,但它确实工作。

In the end, I just dropped the DLL into an appropriately configured MVC app and it worked just like if it had been part of the MVC app from the start. I pushed it a bit further and it worked with 5 of these little mini-MVC plugins just fine. Obviously, you have to watch your references and config dependencies when shuffling it all around, but it did work.

这次演习的目的是插件功能的基于MVC的平台,我要建一个客户端。有一组核心控制器和视图的由多个可选的人在网站的每个实例增加。我们将要作出的可选位到这些模块化的DLL插件。到目前为止好。

The exercise was aimed at plugin functionality for an MVC-based platform I'm building for a client. There are a core set of controllers and views that are augmented by more optional ones in each instance of the site. We're going to be making those optional bits into these modular DLL plugins. So far so good.

我写了我的原型进行了概述,并对于ASP 样品溶液.NET MVC插件的我的网站上。

I wrote up an overview of my prototype and a sample solution for ASP.NET MVC plugins on my site.

编辑:4年过去了,我已经做了不少的ASP.NET MVC应用程序与插件和不再使用我上面描述的方法。在这一点上,我运行全部通过MEF我的插件,不要把控制器进入插件在所有。相反,我作出这样的使用路由信息来选择MEF插件和手头工作过的插件通用控制器等想我要补充,因为这个答案被击中公平一点。

4 years on, I've been doing quite a few ASP.NET MVC apps with plugins and no longer use the method I describe above. At this point, I run all of my plugins through MEF and don't put controllers into plugins at all. Rather, I make generic controllers that use the routing information to select MEF plugins and hand the work off to the plugin, etc. Just thought I'd add since this answer gets hit a fair bit.

这篇关于插件架构的ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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