static PackageDB CloneBySerialization(PackageDB db) { using (var m = new MemoryStream()) { using (var w = new CKBinaryWriter(m, Encoding.UTF8, true)) { db.Write(w); } m.Position = 0; using (var r = new CKBinaryReader(m, Encoding.UTF8, true)) { return(new PackageDB(r)); } } }