王爷爱上青楼里的我,youtube解禁,垂钓之王攻略
该文章是系列文章 基于.netcore和abp框架如何让windows服务执行quartz定时作业 的其中一篇。
windsor是abp框架自带的ioc容器。
关于什么是ioc,你可以bing或者google一下,英文不错的话推荐看一看 。
更多关于castle windsor 可以阅读下列文章
现在比较常用的di组件可以访问awesome系列查看:
问题点在于abp框架使用的是castle windsor,而微软提供的官方容器是microsoft.extensions.dependencyinjection。
这就涉及到一个使用castle windsor替换microsoft.extensions.dependencyinjection的问题。
castle windsor提供了注册的方法,自己实现的话,可以通过循环访问微软自带di容器,将其一一注册到castle windsor容器。
也可以nuget引用一个包:castle.windsor.msdependencyinjection,源码查看:
代码改自如何在控制台应用(.net core)使用appsettings.json配置,需要再添加两个包
microsoft.extensions.hosting castle.windsor.msdependencyinjection
需要添加以下代码
public iconfiguration appconfiguration { get; set; } public override void preinitialize() { var host = new hostbuilder().configureappconfiguration((hostcontext, configapp) => { var hostingenvironment = hostcontext.hostingenvironment; appconfiguration = appconfigurations.get(hostingenvironment.contentrootpath, hostingenvironment.environmentname); }).configureservices((hostcontext, services) => { services.addsingleton(appconfiguration); windsorregistrationhelper.createserviceprovider(iocmanager.ioccontainer, services); }); host.build(); }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论