/// <summary> /// XML-deserializes an object from a binary stream. /// </summary> public static T DeserializeBin <T>(BinaryReader r) { Int32 xmlDataLength = r.ReadInt32(); byte[] xmlData = new byte[xmlDataLength]; r.Read(xmlData, 0, xmlDataLength); MemoryStream ms = new MemoryStream(xmlData); T obj; using (TextReader tr = new StreamReader(ms)) { obj = XmlSerializerExt.Deserialize <T>(tr); } return(obj); }