如何制作“仪表板”接受模块/插件的实用程序

发布于 2024-10-18 04:38:22 字数 538 浏览 2 评论 0原文

我希望这个问题有意义。基本上,我正在寻找一套指南,甚至是一个教程,它将展示如何制作一个可以轻松添加和删除“模块”或“加载项”的应用程序

,例如,在 Microsoft Office 中,您通常会看到您可以下载并安装这些程序,它们只会在 Microsoft Word(例如)中添加一个额外的选项卡,以实现一些新功能。

我有几个使用基本相同数据源的应用程序,我想整合它们,并保留将来添加更多功能的可能性,而无需 1. 需要全新安装 2. 调整我的每一段代码。

我主要是在寻找一个起点。

提前致谢。

**

编辑:详细说明一下...... 我具体想到的是一个应用程序,它访问存储在文本文件中的大量数据,并使用一些数据来创建一些图表,也许还有一些表格。我希望将来能够使用相同的数据添加不同的图表。因此,您可以单击 Button_A 并生成 Graph_A,然后几周后,您可以单击 Button_B 并生成 Graph_B。

如果我能想出一种只需要从文件中读取数据一次的方法,那就太好了,但我知道这需要稍微调整我的 DataReader 类。

I hope this question makes sense. Basically, I am looking for a set of guidelines, or even a tutorial, that will show how to make an application that can easily add and remove "modules" or "add-ins"

For example, in Microsoft Office, you will commonly see programs that you can download and install and they will just add an extra tab into Microsoft Word (for example) that will implement some new feature.

I have several applications that use basically the same data source, and I'd like to consolidate them and also leave open the possibility of adding more functionality in the future without 1. Requiring a brand new install and 2. Tweaking every piece of my code.

I'm looking for a place to start, mostly.

Thanks in advance.

**

Edit: To elaborate a little more...
The thing I have in mind specifically is an application that accesses a large set of data that is stored in text files and uses some of the data to create a few graphs and maybe some tables. I'd like the ability to add different graphs in the future using the same data. So, you can click Button_A and generate Graph_A, then a few weeks later, you can click Button_B and generate Graph_B.

It would be really nice if I could come up with a way that only required reading the data from the file(s) once, but I know that would involve having to adjust my DataReader class a bit.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

黯然 2024-10-25 04:38:22

一个起点是为未来的模块定义一个接口,并构建一个实用程序来扫描其中的所有 dll,寻找实现所述接口的类。

一旦找到支持类,您就可以在运行时创建实例并将其添加到您的应用程序中。这是 .NET 中支持“插件”的常见习惯用法

Activator 类是在运行时从 Type 创建实例的常见方法。

http://msdn.microsoft.com/en-us/library/system .activator.aspx

如果问题中没有更多信息,很难提供更多详细信息。你能详细说明一下吗?

One place to start would be to define an interface for your future modules, and build a utility that scans all the dll's therein, looking for classes that implement said interface.

Once you've found supporting classes you can create instances at runtime and add to your application. That's a common idiom in .NET for supporting "plug-ins"

The Activator class is a common way to create instances from a Type at runtime.

http://msdn.microsoft.com/en-us/library/system.activator.aspx

It's hard to give more details without more info in your question. Can you elaborate a bit?

ゃ人海孤独症 2024-10-25 04:38:22

查看 Microsoft 的复合应用程序库

它针对的是 WPF,但您可以从中获得一些想法。

Take a look at the Composite Application Library from Microsoft.

It is aimed at WPF but you could get some ideas from there.

岁月如刀 2024-10-25 04:38:22

正如 Adam 所说,要做的第一件事是定义插件模块的接口 - 它们期望从容器接收什么,容器必须能够调用哪些方法?

就容器本身而言,我偏爱 MEF 作为定位技术;当添加新的 DLL 时,您可以创建目录并重新构建系统。我已经构建了一个与此类似的系统,用于解析不同的文件,并且 MEF 的组合功能对于运行时发现非常有用。

As Adam said, the first thing to do is define the interface for your plugin modules - what can they expect to receive from the container, and what methods must the container be able to call?

As far as the container itself goes, I'm partial to MEF as a location technology; you can create catalogs and re-compose the system when new DLLs are added. I've built a similar system to this for parsing dissimilar files, and the composition capabilities of MEF are awesome for runtime discovery.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文