组织 MEF 组件

发布于 2024-11-25 10:22:01 字数 281 浏览 1 评论 0原文

为了确保我们采用正确的方法来构造 MEF 插件,存在关于将每个插件作为单独的程序集是否有意义的争论。

例如,假设我们有一个数据处理器解决方案,并且在其中我们开始为我们收到的每种不同类型的数据文件开发不同的处理器。当每个处理器上线时,我们希望能够让 MEF 目录包含这个新插件。然而,由于 VS 和我们的构建环境中的性能受到影响,我们担心包含约 100 个项目的解决方案。

我认为将每个处理器隔离到单个程序集中,保持该程序集的责任有限是有意义的。但这是有代价的。

有谁知道一种方法是否比另一种方法更好?

In an effort to ensure we take the right approach in structuring our MEF plugins, there is a debate about whether it makes sense to have each plugin as a separate assembly.

For example, assume we have a DataProcessors solution and in it we begin to develop different processors for each of the different types of data files we receive. As each processor comes online, we want to be able to have the MEF catalog include this new plugin. However, we are concerned about having a solution with ~100 projects in it due to the performance hit in VS and in our build environment.

I think it makes sense to isolate each of these processors into a single assembly keeping the responsibility of that assembly finite. But there is a cost.

Does anyone have any experience with whether one approach would work better than the other?

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

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

发布评论

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

评论(2

千笙结 2024-12-02 10:22:01

我必须处理的情况与您的情况略有不同,因为我的每个项目都包含一个“模块”,其中包含许多 MEF 导出的功能。
如果我打算单独分发它们或计划向每个客户端分发不同的功能,我通常只会将它们分成不同的程序集。

我认为您不应将其与在没有 MEF 的情况下组织类和集会时所做的决定区别对待。如果您总是通过所有这些导出来发布所有产品,请将它们全部包含在一个装配中。

不过,我很想听听其他人的意见!

The situations I've had to deal with are slightly different to yours in that each of my projects contains a 'module' which contains a lot of functionality with many MEF exports.
I generally only separate off into different assemblies if I intend on distributing them separately or plan to distribute different functionality to each client.

I don't think you should treat it differently to the decisions you make when organising your classes and assemblies without MEF. If you always release all of your products with all of these exports, include all of them in one assembly.

I would be very interested to hear others views though!

囚你心 2024-12-02 10:22:01

没有真正正确或错误的答案。您可能决定将多个处理器捆绑到同一个程序集中,或者可以使用每个程序集的方法。后者为您提供了最大的灵活性,但前者在分发方面可能更有效。

我会查看您打算进行的更新频率,并可能围绕公共基本数据类型或操作将它们组织成处理器组。

例如,我可以有一个整数处理器组件和另一个字符串处理器组件。

正如我所说,这样做没有正确或错误的方法。

There is no real right or wrong answer. You may decide that you can bundle multiple processors into the same assembly, or you could use a per-assembly approach. The later gives you maximum flexibility, but the former is probably more efficient when it comes to distribution.

I'd look at frequency of updates you intend to make, and perhaps organise them into groups of processors, around a common base data type or action.

E.g. I could have an assembly of integer processors, and another assembly of string processors.

As I said, there is no right or wrong way of doing this.

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