紙殼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