You should probably add the following function to your
Envelope
class:
public abstract Type GetBodyType();
And then implement it in the derived class
Envelope<T>
:
return typeof(T);
Or maybe you need to reconsider the whole design... Are you trying to convert a pattern from another language?