*strong text*I have a base class with a method in it for synchronizing data. However I need to be able to create a new object in the process that is the same as the parent object that inherited the base class.
I want to do something like this:
Sub Transfer(ByVal OBType As BaseClass)
Dim A as new typeof(OBType)
A.doSomething()
End Sub
EDIT
I appologize for any confusion
My use case is that I’m transfering data between two objects and the method is responsible for merging the changes between them. When the method is called it gets a set of records and then must call a transfer method that synches them. When execution GetDataRow I need to have a new version of the object and I also need a new version to complete the transfer.
Here is a stripped down version of the code:
GetDataRow creates the object form the datarow and transfer data then compares it and makes the necessary changes.
Sub Transfer(ByVal OBType As BaseBLLClass)
'Get a list from each side and synch
Dim DT As DataTable = GetDataMethod() ‘Gets data to transfer
Dim A As OBType
Dim B As OBType
For Each Row As DataRow In DT.Rows
A = New OBType
B = New OBType
GetDataRow(A, Row).TransferData(B)
Next
End Sub
Solution
Public Shared Sub Base_Transfer(Of OBType As BaseBLLClass)()
'Get a list from each side and synch
Dim DT As DataTable = GetDataMethod() ‘Gets data to transfer
Dim A As BaseClassUIM = Activator.CreateInstance(GetType(OBType))
Dim B As BaseClassUIM = Activator.CreateInstance(GetType(OBType))
For Each Row As DataRow In DT.Rows
A = Activator.CreateInstance(GetType(OBType))
B = Activator.CreateInstance(GetType(OBType))
GetDataRow(A, Row).TransferData(B)
Next
End Sub