mariano_donati
Active member
- Joined
- Nov 30, 2005
- Messages
- 41
- Programming Experience
- Beginner
Hi everyone, I'm greatly surprised with this forum, I'm from Argentina, and I member of different forums in spanish, but nothing like vbForums and vbdotnetforum. Well, I have to solve this trouble that I mention below.
I have this client/server application, they send and receive different serialized objects. When I received, for example, in my client application one of this objects, I need to convert it to the right type for using its properties.
Each object I send, inherits from a base class named EventSender. It has a MustOverrides property that returns the class of the object, let's say Message or Image or ClientConnection objects. So the structure that I follow is like this:
Dim ESender As EventSender = CType(DeserializeBytes(Bytes()), EventSender) 'DeserializeBytes() function returns a EventSender object after deserializing the bytes that I pass for param
Select Case ESender.GetObjectClass 'I use the MustOverrideProperty from the EventSenderObject to know wich object I'm receiving
Case Enum.ClientConnection 'Enum that defines different kinds of objects
Dim E As ClientConnection = CType(ESender, ClientConnection)
'Here I use the right properties of the object that I received
Case Enum.Message
Dim E As Message = CType(ESender, Message)
'Same thing...
End Select
--------------
Well, the thing is that I realized that I can't convert a object wich is the base object, into another wich inherits from it!. So, how can I do to know wich object is the application receiving?, and even more important, how can I do to user the correct properties of the object received?.
Thanks a lot for at least read my message.
Regards!.
I have this client/server application, they send and receive different serialized objects. When I received, for example, in my client application one of this objects, I need to convert it to the right type for using its properties.
Each object I send, inherits from a base class named EventSender. It has a MustOverrides property that returns the class of the object, let's say Message or Image or ClientConnection objects. So the structure that I follow is like this:
Dim ESender As EventSender = CType(DeserializeBytes(Bytes()), EventSender) 'DeserializeBytes() function returns a EventSender object after deserializing the bytes that I pass for param
Select Case ESender.GetObjectClass 'I use the MustOverrideProperty from the EventSenderObject to know wich object I'm receiving
Case Enum.ClientConnection 'Enum that defines different kinds of objects
Dim E As ClientConnection = CType(ESender, ClientConnection)
'Here I use the right properties of the object that I received
Case Enum.Message
Dim E As Message = CType(ESender, Message)
'Same thing...
End Select
--------------
Well, the thing is that I realized that I can't convert a object wich is the base object, into another wich inherits from it!. So, how can I do to know wich object is the application receiving?, and even more important, how can I do to user the correct properties of the object received?.
Thanks a lot for at least read my message.
Regards!.