我有一個表格:使用Unity框架,注入System.Windows.Forms.Form中頁
public partial class mdiAuthenticationForm : Form
{
public Services.Authentication.IAuthentication Authenticator { get; set;
public Services.Authentication.IAuthorization Authorizor { get; set; }
,我想對上述兩種屬性注入的具體類。
我有他們每個人的類型,並使用app.config的配置信息。但是,我不想爲每個頁面創建一個接口,只是爲了注入,所以我怎樣才能注入每個頁面?
基本上,我在以下類型元素中的type屬性中放置了什麼,或者,我該如何做?
<type type="" mapTo="mdiAuthenticationForm,project">
<typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
<property name="Authenticator" propertyType="Services.Authentication.IAuthentication,project">
<dependency name="mssqlauth" />
</property>
<property name="Authorizor" propertyType="Services.Authentication.IAuthorization,project">
<dependency name="mssqlautz" />
</property>
</typeConfig>
</type>
我正在使用Unity框架,順便說一句。
謝謝。
編輯:我得到的容器,然後我想用這注:
Container.Configure<InjectedMembers>().ConfigureInjectionFor<mdiAuthenticationForm>();
我想在我的代碼之外沒有任何東西,除了我必須爲接線。我希望儘可能不顯眼,不幸的是這比我想象的要難。 – 2009-05-21 19:29:59