多个项目的温莎城堡配置

发布于 2024-11-06 21:32:58 字数 314 浏览 0 评论 0原文

我有一个包含多个项目的解决方案(一个网站和 DAL/BL 等的各种其他项目)。我正在尝试将 Castle Windsor 集成到业务逻辑中,以帮助我编写一些单元测试(我知道单元测试和 Castle Windsor 确实应该在项目完成之前集成,长话短说)。

我遇到的问题是配置文件,我将 Castle Windsor 配置信息添加到我的 BL 项目 app.config 中,但是当网站或单元测试(两者都在不同的项目中)访问业务逻辑 Castle Windsor 时看来是看自己的配置文件而不是BL里的配置文件。

我当然不必将配置信息添加到解决方案中的每个项目吗?这似乎有点没有意义。

I have a solution with multiple projects (a website and various other projects for DAL/BL etc). I'm trying to integrate Castle Windsor into the business logic to help me with writing some unit tests (I know unit tests and Castle Windsor should really be integrated before a project is finished, long story).

The problem I'm having is with the config files, I added the Castle Windsor config information to my BL projects app.config but when either the website or the unit tests (Both of which are in different projects) access the business logic Castle Windsor seems to look to at their own config files rather than the config file in the BL.

Surely I don't have to add the config information to every project in my solution? That seems a bit pointless.

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

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

发布评论

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

评论(1

打小就很酷 2024-11-13 21:32:58

这比你想象的要容易。在独立配置文件(例如“Components.config”)中配置温莎城堡,并将其放置在某个常用位置。

之后,您只需将此文件“作为链接”添加到您的项目中。当您右键单击某个文件夹或项目并选择“添加现有项目”时,即可实现这一点。在文件浏览器中,检查“添加”按钮中是否有一些箭头。单击此处并选择“添加为链接”。

您会注意到解决方案资源管理器中的配置文件图标有一些箭头,就像 Windows 快捷方式一样。现在单击此链接文件并打开其属性,然后在“构建操作”中选择“始终复制”。就这样!

你不知道如何在温莎城堡中使用独立配置文件吗?查看这篇文章:

请注意,现在您编辑一个文件并同时影响所有链接的文件!

That can be easier than you think. Configure Castle Windsor in an standalone configuration file, for example "Components.config" and place it in some common location.

After that, you only need to add this file "as a link" in your projects. That's achieved when you right-click in some folder or project and you choose "Add existing item". In the file browser, check that in "Add" button there's some arrow. Click there and choose "Add as a link".

You'll notice that your configuration file icon in Solution Explorer has some arrow, like a Windows shortcut. Now click on this linked file and open its properties, and in "Build action" choose "Copy always". That's all!

Don't you know how to use standalone configuration files in Castle Windsor? Check this article:

Note that now you edit one file and you affect all linked ones at once!

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