Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 在解决方案中复制类和对象_Vb.net - Fatal编程技术网

Vb.net 在解决方案中复制类和对象

Vb.net 在解决方案中复制类和对象,vb.net,Vb.net,在我的解决方案中,我有两个项目。其中一个用于文件下载,第二个用于解析文件,第三个用于加载到数据库。在Parse项目中,我拥有以下类: Public Class AMS5520_CUISAMS Implements IDelimeted Implements IXml Private ReadOnly _config As GeneralSettingsSerializer Private ReadOnly _datasource

在我的解决方案中,我有两个项目。其中一个用于文件下载,第二个用于解析文件,第三个用于加载到数据库。在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
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
在collect项目中,我正在使用这些类:

 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
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 enum:

Public Enum Datasource
    AMS5520_CUISAMS
    SOEM
    U2000
    SAM_ESS_CFAN7450
    SAM_ESS_REN7450
End Enum

我这边的第一件事是将这些类放在Datasource项目中。我几乎在我所有的项目数据源enum中使用。我得到了很多间接参考和其他错误。我如何解决这个问题?

听起来VS被3个项目中同名的类搞糊涂了,我无法想象你的代码会比这更糟。从现在的情况来看,似乎有一个类知道如何根据在ctor中传递的枚举执行不同的操作。这些类应该位于同一名称空间中,并且它们的名称应该是唯一的。这应该被编译并导入到其他项目中。@Proputix:正是现在,我在3个不同的项目中有相同的两个类,我正在寻找将它们放在一个项目中并删除rest中的方法,但正如我所说的,我有问题。在这种特殊情况下我怎么做?