I have a generic type:
public class Packet<T> where T : IContent
{
private int id;
public int Id { get { return this.id; } }
private T content;
public T Content { get { return this.content; } }
}
I want to deserialize/serialize instances of this type from/to XML. IContent
is defined like that:
public interface IContent
{
XmlSerializer Serializer{get;}
}
Basically, I would like the Packet
to use the serializer provided by its content to serialize and deserialize its content member. This serializer is in fact an instance of a pre-compiled xml serializer generated by sgen.exe.
Is it possible without making Packet<T>
implementing IXmlSerializable
?