C# s#arp体系结构查询-服务和存储库

C# s#arp体系结构查询-服务和存储库,c#,s#arp-architecture,C#,S#arp Architecture,我的控制器直接使用服务而不是存储库。这些服务位于ApplicationServices项目中: public XYZService ( IBlaRepository BlaRepository, IBla1Repository Bla1Repository ) { Check.Require(BlaRepository != null, "BlaRepository may n

我的控制器直接使用服务而不是存储库。这些服务位于ApplicationServices项目中:

public XYZService
        (
            IBlaRepository BlaRepository,
            IBla1Repository Bla1Repository
        )
        {
            Check.Require(BlaRepository != null, "BlaRepository may not be null");
            this.BlaRepository = BlaRepository;
        ....
这个很好用

存储库的实现如下所示:

public interface IBlaRepository : IRepository<Bla> (placed in Core/DataInterfaces)

public class BlaRepository : Repository<Bla>, IBlaRepository (placed in Data)
公共接口IBlaRepository:IRepository(放置在核心/数据接口中)
公共类存储库:存储库,IBlaRepository(放置在数据中)
有时我可以使用“普通”的sharp架构存储库。有没有办法让他们进入上述服务?我必须在什么地方注册吗

为了澄清这一点,服务的构建者如下所示:

public XYZService
        (
            Repository<UUU> UUURepository
公共XYZ服务
(
存储库存储

希望这是有意义的

谢谢

克里斯

克里斯, 您只需引用存储库即可:

    private readonly IRepository<Bla> _blaRepository; 

    public BlaService(IRepository<Bla> blaRepository) 
    { 
         _blaRepository = blaRepository; 
    }
私有只读存储库;
公共BlaService(IRepository存储库)
{ 
_blaRepository=blaRepository;
}
这将允许Windsor将存储库注入到您的控制器中,而您不需要其他任何东西


Alec

Hm,我认为这是由S#arp通过componentregister.AddComponentsTo自动完成的,即container.addcomponentlifety(“repositoryWithTypedId”、typeof(IRepositoryWithTypedId)、typeof(repositoryWithTypedId)、LifestyleType.PerWebRequest);它在最新的S#arp版本中被删除了吗?谢谢。如果我按照所描述的方式实现接口,一切都会“自动”工作——我会用“普通的S#arp代表”来表达。