我們正在將一個穩定的項目從Castle Windsor 2.5.2遷移到3.0。在遷移到Windsor 3之後,註冊xml的不同實現以及代碼爲一個接口失敗
我們使用混合的xml/api註冊。切換到3.0後,通過ctor注入並以xml定義的參數無法再解析。
舉例說明:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
...
<properties>
<frontEnd.url>http://site.com</frontEnd.url>
<admin.email>[email protected]</admin.email>
</properties>
<components>
...
<component id="ServicesBootstrapperAction"
service="SomeNS.Startup.IBootstrapperAction"
type="SomeNS.Service.ServicesBootstrapperAction, Project-Service"
>
<parameters>
<frontEndUrl>#{frontEnd.url}</frontEndUrl>
<adminEmail>#{admin.email}</adminEmail>
<prohibitedLogins>Assets/prohibited-logins.txt</prohibitedLogins>
</parameters>
</component>
...
</components>
</configuration>
和登記:
_container.Install(
Castle.Windsor.Installer.Configuration.FromXmlFile("project.common.config"),
Castle.Windsor.Installer.Configuration.FromXmlFile(String.Format("project.{0}.config", RuntimeEnvironment))
);
試圖解決這個組件,我們得到後:
'SomeNS.Service.ServicesBootstrapperAction' is waiting for the following dependencies:
- Parameter 'frontEndUrl' which was not provided. Did you forget to set the dependency?
- Parameter 'adminEmail' which was not provided. Did you forget to set the dependency?
- Parameter 'prohibitedLogins' which was not provided. Did you forget to set the dependency?
同樣,這一點是與工作完美2.5所以我想這可能是一些沒有記錄(或者我們沒有理解)的改變。
鑑別診斷,有人嗎?
更新: 我想出了問題並找到了解決方法。我不喜歡它,但它的工作原理。
對於所有的好奇,這裏的鏈接,該項目能說明問題: https://docs.google.com/open?id=0B7XFrOzGfmirSldZUmRQeU9SZDZZVnV5UGhGaGhsUQ
請隨時告訴我,我錯了,我應該已經使用其他一些漂亮的解決方案(什麼?)。
您可以創建一個獨立的失敗測試嗎? – 2012-04-03 00:44:51
@MauricioScheffer,我打算去。但後來我注意到一個涉及.Unless()的代碼,它停止了工作,但仍然以某種方式被允許。長話短說,一些服務被註冊了兩次,並且在運行時被選擇了最後的註冊實現。溫莎允許這種行爲實際上是令人難過的。我仍然有168個測試需要修復。然後我會回到咆哮。 – Kostassoid 2012-04-03 13:02:13
溫莎使用第一個註冊的服務,而不是最後一個,它並不難過,它非常有用並且通過設計。 – 2012-04-03 14:13:24