如何使用插件架构在ASP.NET? [英] How to use Plugin Architecture in ASP.NET?

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

问题描述

我真的很喜欢在WinForms的插件架构。我想使用在Asp.net.BUT插件架构我已经搜索插件的弧线。在asp.net我已经成立asp.net MVC样本。坚果我不希望使用微软的MVC库。我想用经典的asp.net项目。但我没有找到足够的结果....

i really like plugin architecture in WinForms. i want to use plugin architecture in Asp.net.BUT i 've searched plugins arc. in asp.net i 've founded asp.net MVC samples. Nut i don't want to use microsoft mvc repository. i want to use classic asp.net project. But i don't find sufficient result....

推荐答案

您可以滚动你自己的。

一个插件架构需要一些不那么复杂零件:

A plugin architecture needs a few not-so-complex parts:


  • 系统的方法来确定哪些插件DLL位于

  • 一个接口或基类的定义,所有的插件必须坚持。这是最重要的一个。它决定哪些功能的插件可以揭露和有多深它可以与您的应用程序集成

  • 当你的插件被加载并执行的地方(时间)。 (即是否该插件为每个网页请求执行?还是匹配特定名称的要求?抑或是页手动调用插件吗?)

一旦你有了这个想通了,实例化一个插件的一个实例很简单。它的工作原理相同无论你在一个Web应用程序或客户端上运行:

Once you have this figured out, instantiating an instance of a plugin is simple. It works the same regardless of whether you're running in a web app or on the client:

System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom(plugin_path);
t = a.GetType("IPlugin");
IPlugin plugin = (IPlugin)Activator.CreateInstance(t);

那么,你可以使用 plugin.DoSomething()实际上从插件调用功能。 (无论是呈现HTML的一部分,或者保存到数据库或其他)

then, you can use plugin.DoSomething() to actually invoke functionality from the plugin. (Whether it is to render part of the html or save to a DB or whatever)

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

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