纸壳CMS是一个开源免费的可视化内容管理建站系统,拖拽就能够轻松建网站。html
GitHub: http://github.com/SeriaWei/ZKEACMSgit
纸壳CMS在设计上使用的是ASP.Net Core默认的IOC容器,经过依赖注入能够轻松替换掉原来的接口实现。例如在使用纸壳CMS作二次开发的过程当中,可能要接入另外一系统的用户来做为CMS系统的用户。这种状况下,能够不用修改原来的UserService
,而是从新实现一个IUserService,而后用这个新的实现来替换掉旧的UserService
。github
新建纸壳CMS插件很简单,能够参考这篇文章:http://www.zkea.net/codesnippet/detail/zkeacms-plugin-development.htmlide
这个新的UserService
须要继承自IUserService
,并对每个方法作出实现:post
public class CRMUserService : Easy.Modules.User.Service.IUserService { }
在插件的插件类(xxxPlug.cs)中,在ConfigureServices
注册Service的方法中进行注入替换:网站
public override void ConfigureServices(IServiceCollection serviceCollection) { serviceCollection.Replace(new ServiceDescriptor(typeof(IUserService), typeof(CRMUserService), ServiceLifetime.Transient)); }
这样,当系统中获取IUserService
的实例时,获得的就是新的CRMUserService
了。spa
原文地址:http://www.zkea.net/codesnippet/detail/post-179.html.net