asp.net unity中的接口拦截和构造函数注入有什么区别?我对 Unity 的 DI 缺乏了解我正在处理一个旧项目和 unity.config,有些像这样,
<register type="ICRIC2012TrialUserService" mapTo="CRIC2012TrialUserService">
<lifetime type="perthread"/>
<interceptor type="InterfaceInterceptor"/>
<policyInjection/>
</register>
但有些没有
<interceptor type="InterfaceInterceptor"/>
但是在项目中,这些类和接口以相同的方式工作,就像这样
private readonly IIncomingEstimateService _incomingEstimateService;
public ContractService(IIncomingEstimateService incomingEstimateService)
{
_incomingEstimateService = incomingEstimateService;
}