放置将被广泛使用的通用例程的最佳实践是什么?迄今为止,我倾向于在每个项目中都简单地拥有一个ModGlue.vb文件,在该文件中我需要放置任何文件,但是在项目之间移动类需要从ModGlue中查找并复制适当的内容,这有些乏味并且会如果没有更好的策略,我就会变得越长. 一些通用例程是这样的:
What is the best practice for placing general-purpose routines which will be widely used? To date, I''ve tended to simply have a ModGlue.vb file in each project, where I throw any that I need, but moving classes between projects requires locating and copying in the appropriate stuff from ModGlue, which is somewhat tedious and will become moreso the longer I go without a better strategy.Some of the general-purpose routines are things like:
Function Byt(ByVal v as Integer) As Byte<br /> Return CByte(v and 255)<br />End Function<br /><br />Function HexArr(ByVal dat() as Byte) As String '' Returns hex representation of array<br /><br />Function ByteString(ByVal dat() as Byte, ByVal Length As Integer) As String '' Converts bytes to string (by character code)<br /><br />Sub Zap(ByRef it as iDisposable)<br /> Dim oldIt as iDisposable<br /> oldIt = it<br /> If oldIt IsNot Nothing then<br /> oldIt.Dispose<br /> Threading.Interlocked.CompareExchange(it, Nothing, oldIt)<br /> EndIf<br />End Sub在许多情况下,sorta应该是.NET框架的一部分,但不是.在将一个类从一个项目复制到另一个项目而又不会导致多余或重复的方法结束时,确保引入必要功能的最佳方法是什么?
In many cases, things that sorta should have been part of the .Net framework, but aren''t. What''s the best way to make sure that the necessary functions get brought in when copying a class from one project to another, without ending up with extraneous or duplicated methods?
推荐答案构建一个导入到所有项目中的dll. Build a dll you import into all your projects.
更多推荐
常用例程的最佳做法
发布评论