XmlSerializer, sgen.exe and generics
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 as follows:
public interface IContent
{
XmlSerializer Serializer{get;}
}
Basically, I would like to be able to Packet
use the serializer provided by its content to serialize and deserialize its content. This serializer is actually an instance of the precompiled XML serializer generated by sgen.exe.
Is this possible if you don't do the Packet<T>
implementation IXmlSerializable
?
+1
source to share