小编Bub*_*ble的帖子

Microsoft Unity界面拦截和构造函数注入之间的区别

asp.net unity中的接口拦截和构造函数注入有什么区别?我缺乏对Unity的理解我正在研究一个旧项目和unity.config,有些像这样,

<register type="ICRIC2012TrialUserService" mapTo="CRIC2012TrialUserService">
        <lifetime type="perthread"/>
        <interceptor type="InterfaceInterceptor"/>
        <policyInjection/>
</register>
Run Code Online (Sandbox Code Playgroud)

但有些人没有

<interceptor type="InterfaceInterceptor"/>
Run Code Online (Sandbox Code Playgroud)

但是在项目中,这些类和接口以相同的方式工作,就像这样

private readonly IIncomingEstimateService _incomingEstimateService;

        public ContractService(IIncomingEstimateService incomingEstimateService)
        {
            _incomingEstimateService = incomingEstimateService;
        }
Run Code Online (Sandbox Code Playgroud)

c# unity-container code-injection unity-interception

2
推荐指数
1
解决办法
2268
查看次数