[英]Right organization of dependencies between projects in C#
Good afternoon. 下午好。 How should I organize the following structure using C#, the .NET platform, and Visual Studio projects?
我应该如何使用C#,.NET平台和Visual Studio项目组织以下结构?
The solution should contains several projects (dll or winmd as result). 解决方案应包含多个项目(结果为dll或winmd)。
FrameworkB
and FrameworkC
depend on FrameworkA
. FrameworkB
和FrameworkC
依赖于FrameworkA
。 ClassA
from FrameworkA
, ClassD
from FrameworkB
, and ClassF
from FrameworkC
are public and visible to framework users; ClassA
从FrameworkA
, ClassD
从FrameworkB
,并ClassF
从FrameworkC
是公开的,可见的框架的用户; other classes are not accessible to them (there is no possibility to create objects or call a methods). 他们无法访问其他类(不可能创建对象或调用方法)。 In this case, from
ClassE
and ClassG
we should be able to use the methods from ClassB
and ClassC
. 在这种情况下,从
ClassE
和ClassG
我们应该能够使用ClassB
和ClassC
的方法。
So: 所以:
FrameworkA
, FrameworkB
, and FrameworkC
should be a different .dll
or .winmd
files (But B
and C
depend on A
). FrameworkA
, FrameworkB
和FrameworkC
应该是不同的.dll
或.winmd
文件(但B
和C
依赖于A
)。 ClassB
, ClassC
, ClassE
, and ClassG
should be private to framework end-users, but B
and C
should be visible and used by E
and G
. ClassB
, ClassC
, ClassE
和ClassG
应该是框架最终用户的私有,但B
和C
应该是可见的并由E
和G
。 Solution
FrameworkA
ClassA
ClassB
ClassC
FrameworkB
ClassD
ClassE
FrameworkC
ClassF
ClassG
As per this answer , you could use an InternalsVisibleTo attribute and use Internal access modifier on classes B and C. 根据这个答案 ,您可以使用InternalsVisibleTo属性并在类B和C上使用内部访问修饰符。
That way, classes from the first assembly can be used by other two, but not by client written software. 这样,第一个程序集中的类可以由其他两个使用,但不能由客户端编写的软件使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.