我希望能够将模型状态注入服务。
服务
public ThirdPartyService(IValidationDictionary dict)
{
// IValidationDictionary, in this case is a ModelStateWrapper object
// I created to wrap model state
}
登记
builder.Register(x => new ModelStateWrapper(x.Resolve<ControllerType>().ViewData.ModelState))
.As<IValidationDictionary>().InstancePerHttpRequest();
有任何想法吗?