i have have to parse server messages on the client side.
Now i need a perfect design pattern to solve it in a clean way.
I have up to 100 messages, if i got a packet with a correct ID for a Message i want to parse that message. Every message is a class that deserialize the bytes.
Now my problem is to cast each message.
How to declare a dynamic Type.
Expand|Select|Wrap|Line Numbers
- myMessage varP = new myMessage();
- varP.deserialize();
How to get myMessage dynamic that i can cast to 100 Messages without a if block -> if (id ==10) then ...
I had no success doing it like this:
Expand|Select|Wrap|Line Numbers
- Type myMessage = mycollection[10].getType();
- myMessage varP = new myMessage();
It have to be a .net 2.0 solution better would be 1.1 :-)
Could someone give me a hint to solve such dynamics?
thankfull in advance