开发者

Share getter/setter classes across asp.net applications

开发者 https://www.devze.com 2023-04-10 10:25 出处:网络
Maybe there\'s something obvious that I\'m missing or maybe not. Suppose I have a class that is just a representation with getters/setters and no logic. I\'m going to use开发者_运维技巧 these structur

Maybe there's something obvious that I'm missing or maybe not. Suppose I have a class that is just a representation with getters/setters and no logic. I'm going to use开发者_运维技巧 these structures for serialization/deserialization mostly. Suppose I use that object in many, many applications. Suppose I have dozens of these objects. What's my best approach to sharing these objects?

I understand that I can compile an object into a DLL and reference that DLL. But if I have dozens of these objects, do I compile them all separately so I can use just what I need or do I make and maintain a monster DLL with all of these objects in it. Both of those approaches seem bad. I don't want to create a class library for every single class (that's stupid) and throwing them into a giant package just seems like a bad idea.

Am I missing something simple? Doesn't java have a convention where one can create jar files of one to many classes? Does .Net do something like that?


You need a happy middle ground.

You should be grouping related objects into individual namespaces.

You can then compile each namespace into a seperate DLL. That way, whoever is using the libraries only needs to reference a single DLL per group of functionality.


You can have a master assembly containing all objects. Then also create separate assemblies for the different applications where you only add the ones you use as links.

You would then use Project->Add Existing Item, and then on the Add-button click the down-arrow and select "Add As Link" when you add the classes you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消