Ok, this looks junky to me and I tried a lot of approaches; Generics won't allow me to cast the types on the fly and use MemberwiseClone() because it is 'Protected'.
Does anyone know a "short form" of doing this? I tried CType by Object.GetType on the fly; but the IDE cannot resolve the MemberwiseClone().
I am trying to make a generalized function to handle if the Object is Changed; or If the values are different.
This seems like way too much code for such a simple task to me, and I have a lot of classes to compare; is there away to get the class defination dynamically so that the CType function will handle it?
Generics wont allow for Complex Late Binding.
Does anyone know a "short form" of doing this? I tried CType by Object.GetType on the fly; but the IDE cannot resolve the MemberwiseClone().
VB.NET:
Private lastObj as Object = Nothing
Public Function IsObjectedDifferent(CurrentObject as Object) as Boolean
If CurrentObject Is Nothing Then Return False
If LastObject Is Nothing Then Return False
Dim returnValue as Boolean = CurrentObject.Equals(lastObj)
If TypeOf (CurrentObj) Is SomeClassA Then
lastObj = CType(CurrentObj, SomeClassA).MemberwiseClone
ElseIf TypeOf (CurrentObj) Is SomeClassB Then
lastObj = CType(CurrentObj, SomeClassB).MemberwiseClone
ElseIf TypeOf (CurrentObj) Is SomeClassC Then
lastObj = CType(CurrentObj, SomeClassC).MemberwiseClone
.
.
.
ElseIf TypeOf (CurrentObj) Is SomeClassZ Then
lastObj = CType(CurrentObj, SomeClassZ).MemberwiseClone
End If
Return returnValue
End Function
I am trying to make a generalized function to handle if the Object is Changed; or If the values are different.
This seems like way too much code for such a simple task to me, and I have a lot of classes to compare; is there away to get the class defination dynamically so that the CType function will handle it?
Generics wont allow for Complex Late Binding.
Last edited: