Silverlight 4 应用程序中的 MEF 和 Autofac
刚刚开始开发一个复合应用程序,该应用程序将多目标 WPF 和Silverlight 4。我们很可能会允许一些第 3 方插件。此外,我们希望将 Silverlight 应用程序划分为多个可以独立下载/加载的 XAP。
我们曾认为使用 MEF 来控制应用程序的扩展点(即模块组成)并使用 Autofac 来处理模块内的依赖关系将是可行的方法。
不过,问题就在这里。 Autofac 似乎没有 SL4 MEF 集成,因此我们不能简单地在 Silverlight 代码中注册目录中的类型。由于我们使用 XAP 对应用程序进行分区,因此需要使用 MEF DeploymentCatalog 在下载新 XAP 时将其拉入。我们曾考虑过通过程序集简单地将类型注册到 Autofac(主要是视图和视图模型)中,但似乎没有办法通过 DeploymentCatalog 获取程序集。我们错过了什么吗?有没有办法在下载后获取 DeploymentCatalog 中的程序集?我们看待这个问题的方式是否错误?
如果这还不够,请随时询问更多详细信息。任何帮助总是非常感激。
干杯,
史蒂夫
Just started working on a composite App that will multi-target WPF & Silverlight 4. It's quite likely that we'll allow some 3rd party plugins. Also, we'd like to partition the Silverlight app into multiple XAPs that can be independently downloaded/loaded.
We had thought that using MEF to control the Extension points (i.e. module composition) of the app and Autofac to handle dependencies within modules would be the way to go.
Here's the rub, though. Autofac doesn't appear to have SL4 MEF integration, so we can't simply register types from catalogs in the Silverlight code. Since we're using XAPs to partition the app, we need to use the MEF DeploymentCatalog to pull the new XAPs in as they download. We had considered simply registering types into Autofac (mostly views & viewmodels) by assembly, but there doesn't appear to be a way to get at the assemblies via the DeploymentCatalog. Are we missing something? Is there a way to get at the assemblies in the DeploymentCatalog after it downloads? Are we looking at this in the wrong way?
Feel free to ask for more detail if this isn't sufficient. Any help is always much appreciated.
Cheers,
Steve
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在这里遇到阻力,我想说您最好的选择是 100% 采用 MEF 或 Autofac。
两者之间的集成对于简单的插件场景效果很好,但 Silverlight 中吸引人的 MEF 功能源于 MEF 的“点亮”功能,而 Autofac 不支持该功能。
希望这有帮助,
尼克
If you're hitting friction here, I'd say your best bet is to embrace either MEF or Autofac 100%.
The integration between the two works well for simple plug-in scenarios, but the MEF features that are appealing in Silverlight stem from MEF's "light up" capabilities, which Autofac does not support.
Hope this helps,
Nick
不在 Autofac 中注册类型怎么样?我的想法是,非常类似于 解决任何问题 方法,您可以创建一个注册源来调解对“后端”部署目录的解析请求。
What about not registering types in Autofac? What I'm thinking is that, very much like the Resolve Anything approach, you could make a registration source that mediates resolve requests to the "back-end" deployment catalog.