我有一个包含以下构造函数的类
public BiddingTierSetViewModelValidator(
IPropertyValidator allTiersMustBeContiguous,
IPropertyValidator firstItemMustHaveZeroStartValue,
IPropertyValidator lastItemMustHaveNullEndValue,
IPropertyValidator allExceptLastItemMustHaveNonNullEndValue,
IPropertyValidator biddingTierViewModelValuesCorrect)
当我运行应用程序时,我收到此错误
Missing dependency.
Component <namespace>.BiddingTierSetViewModelValidator has a dependency on FluentValidation.Validators.IPropertyValidator, which could not be resolved.
Make sure the dependency is correctly registered in the container as a service, or provided as inline argument.
我希望能够做的是我希望在不同的实现中传递的每个IPropertyValidator
参数。我如何在温莎设置这个?
答案 0 :(得分:2)
您可以将te构造函数更改为:
public BiddingTierSetViewModelValidator(IPropertyValidator [] propertyValidators)
注册容器中的所有验证器并添加以下内容:
container.Kernel.Resolver.AddSubResolver(new CollectionResolver());
祝你好运,
Marwijn。