ABP使用外部XML文件運行期動態進行依賴注入

ABP使用外部XML文件運行期動態進行依賴注入

 

public class DacongApplicationModule : AbpModule
    {
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
            IocManager.IocContainer.Install(Castle.Windsor.Installer.Configuration.FromXmlFile("dependencies.config"));
        }
    }

 

dependencies.config文件

 

<configuration>
<components>
    <component
      id="uniqueId"
      service="Acme.Crm.Services.INotificationService, Acme.Crm"
      type="Acme.Crm.Services.EmailNotificationService, Acme.Crm"
      inspectionBehavior="all|declaredonly|none"
      lifestyle="singleton|thread|transient|pooled|scoped|bound|custom"
      customLifestyleType="type that implements ILifestyleManager"
      componentActivatorType="type that implements IComponentActivator"
      initialPoolSize="2" maxPoolSize="6">
    </component>
</components>
</configuration>

 

參考

https://github.com/castleproject/Windsor/blob/master/docs/xml-registration-reference.md

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章