.NET 4.5中Visual Studio解决方案中的项目引用

时间:2017-10-26 04:58:01

标签: c# .net visual-studio architecture

我目前正在开展一个项目,我试图通过“反腐败层”来重构某些代码。

这是项目的现状:

[WebSolution.Api]
[WebSolutions.Services]

[WebSolution.Api]⇢[WebSolutions.Services]⇢ superPackage

目前的问题是[WebSolutions.Services]目前正在使用我们试图摆脱的NuGet包(我们称之为 superPackage )。

不幸的是,NuGet包太深入地集成在[WebSolutions.Services]项目中。

作为临时步骤,我们要做的是通过反腐败层提取依赖性。

这是项目的新状态:

[WebSolution.Api]
[WebSolutions.Services]
[WebSolutions.Dependency]

[WebSolution.Api]⇢[WebSolutions.Services]⇢[WebSolutions.Dependency]⇢ superPackage

我的尝试如下:

  • 在[WebSolutions.Dependency]中创建一个接口 superPackage 的适配器

  • 将[WebSolutions.Services]中的呼叫移至 superPackage ,而不是调用[WebSolutions.Dependency],然后调用 superPackage

我面临的挑战是当我从[WebSolutions.Services]中删除 superPackage NuGet包时,添加了对[WebSolutions.Dependency]的项目引用,编译器抛出错误,坚持认为 superPackage 需要[WebSolutions.Services]引用。

我假设由于[WebSolutions.Dependency]对 superPackage 具有NuGet依赖性,因此从[WebSolutions.Services]引用[WebSolutions.Dependency]将给出我是那些免费的依赖。

请欣赏任何建议。

1 个答案:

答案 0 :(得分:0)

确保您不使用从Api和服务调用的界面功能中的任何“superPackage”类。