Windsor不解析类构造函数依赖项

时间:2010-05-14 17:15:29

标签: c# castle-windsor

我有代码(简化)

配置:

_container.AddComponent<IRepository<Project>, FakeProjectRepository>();
var instance = new List<Project>();
_container.Kernel.AddComponentInstance<IList<Project>>(instance);

类别:

class FakeProjectRepository: IRepository<Project>
public FakeProjectRepository(IList<Project> entities)
    {
        _entities = entities.ToList();
    }

解析container.Resolve(repositoryType)时抛出

Can't create component 'Domain.Concrete.FakeRepositories.FakeProjectRepository' 
as it  has dependencies to be satisfied. 

Domain.Concrete.FakeRepositories.FakeProjectRepository
is waiting for the following dependencies: 

Keys (components with specific keys)
- entities which was not registered.

1 个答案:

答案 0 :(得分:2)

列表通常不被视为独立服务,而是作为服务覆盖或参数。请参阅Windsor FAQWindsor documentation on Resolvers