/// <summary> /// XML-serializes an object into a binary stream. /// </summary> public static void SerializeBin <T>(T obj, BinaryWriter w) { MemoryStream ms = new MemoryStream(10000); XmlWriterSettings ws = new XmlWriterSettings { Indent = false }; using (TextWriter tw = new StreamWriter(ms)) { XmlSerializerExt.Serialize(obj, tw, ws); } byte[] xmlData = ms.ToArray(); w.Write(xmlData.Length); w.Write(xmlData); }