构建我自己的类库框架 [英] Building my own class library framework

查看:70
本文介绍了构建我自己的类库框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我们正在构建我们自己的类库框架,其中包含的东西

可用于各种客户的各种项目。


最初我们有4个装配,其中包含所有内容。当然,当

项目A只需要一个类时,它会获得程序集中的所有内容

;我们不希望这样。


现在我们为每个控件或主要功能创建一个程序集,所以

项目必须添加一个引用它真正需要的组装。

但是现在,我们引入了循环引用和依赖的危险

问题;它很难维护。


是否有一个干净的解决方案,以确保项目只获得他们真正需要的

课程,但没有困难有很多

的组件?也许在构建时选择需要哪些组件

然后用只需要的东西构建一个程序集?


你有什么想法?

Hi all,

we are building our own class library framework, with stuff in it that
can be used in various projects at various clients.

Initially we had 4 assemblies with everything in it. Of course, when
project A only needs one class, it gets everything in the assembly
also; and we don''t want that.

Now we create an assembly for each control or main functionality, so
the project has to add a reference to the assembly it really needs.
But now, we introduce danger for circular references and dependency
issues; it''s harder to maintain.

Is there a clean solution to make sure that projects only get the
classes they really need, but without the difficulties of having a lot
of assemblies? Maybe select what components are needed at build time
and then build an assembly with only the needed stuff?

What are your ideas?

推荐答案

12月4日上午11:21,Ludwig< lstuyc ... @ gmail.comwrote:
On Dec 4, 11:21 am, Ludwig <lstuyc...@gmail.comwrote:

我们正在构建我们自己的类库框架,其中包含的内容

可用于各种客户的各种项目。


最初我们有包含所有内容的4个组件。当然,当

项目A只需要一个类时,它会获得程序集中的所有内容

;我们不希望这样。
we are building our own class library framework, with stuff in it that
can be used in various projects at various clients.

Initially we had 4 assemblies with everything in it. Of course, when
project A only needs one class, it gets everything in the assembly
also; and we don''t want that.



为什么不呢?你遇到了什么问题?


毕竟,想想主要的.NET框架 - 我怀疑你是否使用所有类中的
mscorlib.dll或System.dll ...


在我看来,维护少量的大型
组件比反之亦然。


Jon

Why not? What problem are you running into?

After all, think of the main .NET framework - I doubt that you''re
using all the classes in mscorlib.dll or System.dll...

In my view it''s much easier to maintain a small number of large
assemblies than vice versa.

Jon


4月12日,12:39,Jon Skeet [C#MVP] < sk ... @ pobox.comwrote:
On 4 dec, 12:39, "Jon Skeet [C# MVP]" <sk...@pobox.comwrote:

12月4日上午11:21,Ludwig< lstuyc ... @ gmail.comwrote:
On Dec 4, 11:21 am, Ludwig <lstuyc...@gmail.comwrote:

我们正在构建我们自己的类库框架,其中包含的内容

可用于各种客户的各种项目。
we are building our own class library framework, with stuff in it that
can be used in various projects at various clients.


最初我们有4个程序集,其中包含所有内容。当然,当

项目A只需要一个类时,它会获得程序集中的所有内容

;我们不希望这样。
Initially we had 4 assemblies with everything in it. Of course, when
project A only needs one class, it gets everything in the assembly
also; and we don''t want that.



为什么不呢?你遇到了什么问题?


毕竟,想想主要的.NET框架 - 我怀疑你是否使用所有类中的
mscorlib.dll或System.dll ...


在我看来,维护少量的大型
组件比反之亦然。


Jon


Why not? What problem are you running into?

After all, think of the main .NET framework - I doubt that you''re
using all the classes in mscorlib.dll or System.dll...

In my view it''s much easier to maintain a small number of large
assemblies than vice versa.

Jon



没问题 - 但问题是,如果客户需要特定的

控制,他应该得到那个控制而不是整个库,

包含他没有付出的成分。

No problem - but the thing is, that if the client needs a particular
control, he should just get that control instead of the whole library,
with components he didn''t pay for.





" Ludwig"写道:


"Ludwig" wrote:

4月12日,12:39,Jon Skeet [C#MVP] < sk ... @ pobox.comwrote:
On 4 dec, 12:39, "Jon Skeet [C# MVP]" <sk...@pobox.comwrote:

12月4日上午11:21,Ludwig< lstuyc ... @ gmail.comwrote:
On Dec 4, 11:21 am, Ludwig <lstuyc...@gmail.comwrote:

我们正在构建我们自己的类库框架,其中包含的内容

可用于各种客户的各种项目。
we are building our own class library framework, with stuff in it that
can be used in various projects at various clients.


最初我们有4个程序集,其中包含所有内容。当然,当

项目A只需要一个类时,它会获得程序集中的所有内容

;我们不希望这样。
Initially we had 4 assemblies with everything in it. Of course, when
project A only needs one class, it gets everything in the assembly
also; and we don''t want that.



为什么不呢?你遇到了什么问题?


毕竟,想想主要的.NET框架 - 我怀疑你是否使用所有类中的
mscorlib.dll或System.dll ...


在我看来,维护少量的大型
组件比反之亦然。


Jon

Why not? What problem are you running into?

After all, think of the main .NET framework - I doubt that you''re
using all the classes in mscorlib.dll or System.dll...

In my view it''s much easier to maintain a small number of large
assemblies than vice versa.

Jon



没问题 - 但问题是,如果客户需要特定的

控制,他应该只是控制而不是整个库,

包含他没有支付的组件。


No problem - but the thing is, that if the client needs a particular
control, he should just get that control instead of the whole library,
with components he didn''t pay for.



那是一个非常不同的问题。您可以查看某种形式的

许可方案。或者,您可以为每个

销售产品创建库。每种产品都可能依赖于与产品一起分发的一个或多个核心组件



That is a very different question then. You could look at some form of
licensing scheme. Alternatively you could create libraries for each of your
sales products. Each product could depend on one or more core assemblies
that are distributed with the product.


这篇关于构建我自己的类库框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆