在ABP框架中有一个约定,所有的领域服务都应该继承并实现IDomainService接口,在领域层Core创建某一个实体的领域服务类,继承并实现IDomainService接口。在ABP框架中,领域服务类的命名习惯一般时xxxManager。
namespace MyTestProject.ShoppingGoods
{
/// <summary>
/// 领域服务接口
/// </summary>
public interface IGoodsManager:IDomainService
{
//书写接口
}
}
namespace MyTestProject.ShoppingGoods
{
/// <summary>
/// 领域服务
/// </summary>
public class GoodsManager : DomainService, IGoodsManager
{
public GoodsManager()
{
}
//实现接口
}
}
在AppService中将IGoodsManager 注入进去
namespace MyTestProject.ShoppingGoods
{
public class GoodssAppService : MyTestProjectAppServiceBase, IApplicationService
{
public readonly IGoodsManager _goodsManager;
public GoodssAppService(IGoodsManager goodsManager)
{
_goodsManager = goodsManager;
}
}
}