(_Objeto1 _Objeto2). -, . -, (_AnyObject.GetType.ToString). -, . , FALSE. TRUE.
( ). , , ..
Microsoft.VisualBasic
System.Reflection
Public Function CompararObjetos (ByVal _Objeto1 As Object, ByVal _Objeto2 As Object) As a logical
Dim _TipoObjeto1 As String = ""
Dim _TipoObjeto2 As String = ""
If Not _Objeto1 Is Nothing Then
_TipoObjeto1 = _Objeto1.GetType.ToString
End If
If Not _Objeto2 Is Nothing Then
_TipoObjeto2 = _Objeto2.GetType.ToString
End If
Dim _Resultado As Boolean = True
If _TipoObjeto1 = _TipoObjeto2 Then
Dim Propiedades() As PropertyInfo = _Objeto1.GetType.GetProperties
Dim Propiedad As PropertyInfo
Dim _Valor1 As Object
Dim _Valor2 As Object
For Each Propiedad In Propiedades
_Valor1 = Propiedad.GetValue(_Objeto1, Nothing)
_Valor2 = Propiedad.GetValue(_Objeto2, Nothing)
If _Valor1 <> _Valor2 Then
_Resultado = False
Exit For
End If
Next
Else
_Resultado = False
End If
Return _Resultado
End Function
source
share