Ejemplo n.º 1
0
 public static void Serialize <T>(
     TextWriter writer,
     T instance,
     XmlSerializableSettings settings = null)
 {
     using (var xmlWriter = XmlTextWriter.Create(writer, WriterSettings)) {
         Serialize(xmlWriter, instance, settings);
     }
 }
Ejemplo n.º 2
0
 public static void Serialize <T>(
     Stream stream,
     T instance,
     XmlSerializableSettings settings = null)
 {
     using (var writer = new StreamWriter(new SharedStream(stream))) {
         Serialize(writer, instance, settings);
     }
 }
Ejemplo n.º 3
0
 public static void Serialize <T>(
     XmlWriter writer,
     T instance,
     XmlSerializableSettings settings = null)
 {
     if (typeof(XmlSerializable).IsAssignableFrom(typeof(T)))
     {
         var serializable = ((XmlSerializable)(object)instance);
         serializable.Settings = settings ?? serializable.Settings;
         serializable.WriteXml(writer, emitRoot: true);
     }
     else
     {
         new XmlSerializable <T>(instance, settings).WriteXml(writer, emitRoot: true);
     }
 }