1

I've always created XmlSerializer instances starting from the types I need to be serialized. Something like

new XmlSerializer(typeof(MyType))

I have a pretty system which allow to plug application types to be serialized along with the base classes (using the XmlSerializer). The XmlSerializer instances are mapped on the base types, but I can add additional types used by the application in order to serialize types not known statically.

Sadly, this system requires that the application specify which additional types must be included in the serializer.

So, I'd like to define an XSD schema which defines how types are really serialized (a sort of XML serializer configuration), and then create a XmlSerializer which is able to serialize/deserialize the types defined in my XSD schema.

Is it possible?

May would it be possible to create an assembly (using sgen.exe) starting from a XSD schema?

Luca
  • 11,646
  • 11
  • 70
  • 125

1 Answers1

1

You can use XSD.EXE in order to generate your C# classes to match your given schema, and then serialize to and from those. Once you have the classes, you can use CodeDomProvider to generate the assembly.

GWLlosa
  • 23,995
  • 17
  • 79
  • 116