在我的解决方案中,我有几个项目。其中一个用于文件下载,第二个项目用于解析文件,第三个用于加载到数据库。在Parse项目中我有这些类:
Public Class AMS5520_CUISAMS
Implements IDelimeted
Implements IXml
Private ReadOnly _config As GeneralSettingsSerializer
Private ReadOnly _datasource As Datasource
#Region "CONSTRUCTORS"
Public Sub New(ByVal mygeneralConfig As GeneralSettingsSerializer, ByVal datasource As Datasource)
_config = mygeneralConfig
_datasource = datasource
End Sub
#End Region
Public Sub Delimeted() Implements IDelimeted.Delimeted
'Delimeted class belongs to Parser project
Dim del As New Delimeted(_config, _datasource)
del.Run()
End Sub
Public Sub Xml() Implements IXml.Xml
XML class belongs to Parser project
Dim xml As New XML(_config, _datasource)
xml.Run()
End Sub
End Class
Public Class U2000
Implements IDelimeted
Private ReadOnly _config As GeneralSettingsSerializer
Private ReadOnly _datasource As Datasource
#Region "CONSTRUCTORS"
Public Sub New(mygeneralConfig As GeneralSettingsSerializer, datasource As Datasource)
_config = mygeneralConfig
_datasource = datasource
End Sub
#End Region
Public Sub Delimeted() Implements IDelimeted.Delimeted
Dim del As New Delimeted(_config, _datasource)
del.Run()
End Sub
End Class
Inside collect项目我正在使用这些类:
Public Class AMS5520_CUISAMS
Inherits Collect
#Region "CONSTRUCTORS"
Public Sub New(mygeneralConfig As GeneralSettingsSerializer, datasource As Datasource)
MyBase.New(mygeneralConfig, Datasource)
End Sub
#End Region
End Class
Public Class U2000
Inherits Collect
#Region "CONSTRUCTORS"
Public Sub New(mygeneralConfig As GeneralSettingsSerializer, Datasource As Datasource)
MyBase.New(mygeneralConfig, Datasource)
End Sub
#End Region
End Class
Inside Loader project I have those two classes:
Public Class AMS5520_CUISAMS
Inherits Load
#Region "CONSTRUCTORS"
Public Sub New(mygeneralConfig As GeneralSettingsSerializer, datasource As Datasource)
MyBase.New(mygeneralConfig, datasource)
End Sub
#End Region
End Class
Public Class U2000
Inherits Load
#Region "CONSTRUCTORS"
Public Sub New(mygeneralConfig As GeneralSettingsSerializer, datasource As Datasource)
MyBase.New(mygeneralConfig, datasource)
End Sub
#End Region
End Class
正如你所看到的那些类是相同的,我想知道如何减少它,我只能在一个地方减少它,而这三个项目可以引用它们而不重复。
我还有Datasource项目,其中包含我在这些项目中使用的Datasource枚举:
Public Enum Datasource
AMS5520_CUISAMS
SOEM
U2000
SAM_ESS_CFAN7450
SAM_ESS_REN7450
End Enum
我的第一件事就是将这些类放在Datasource项目中。我几乎在我的所有项目Datasource enum中使用。然后我得到了很多间接引用和其他错误。我该如何解决这个问题?