I have the following simplistic:
Type type; //тип класса, производного от Request (в данном случае ConcretRequest) Request request; You need to do the following:
ConcretRequest concretRequest = (ConcretRequest)request; How to do it?
Update:
I need it to transfer data to the server. Objects of classes derived from Request are containers for data. On the client side, I serialize them and create an object of the class containing the result of the serialization and the type of the serialized object:
public class RequestPacket { public Type type; public byte[] requestBytes; } Serialize RequestPacket and send to server. On the server I deserialize in RequestPacket . Next, I need to deserialize requestBytes into an instance of a class derived from Request .
I have a feeling that I reinvent the wheel. But I just can not find how this can be done easier.