public void Deserialize() { string homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); string filePath = Path.Combine( homePath, "repos", "mjcheetham", "git", ".git", "index"); byte[] inputBytes = File.ReadAllBytes(filePath); using var inputStream = new MemoryStream(inputBytes); Index index = IndexSerializer.Deserialize(inputStream); using var outputStream = new MemoryStream(); IndexSerializer.Serialize(index, outputStream); byte[] outputBytes = outputStream.ToArray(); Assert.Equal(inputBytes, outputBytes); }
public void Close(bool removeOldEntries) { // See if we have any stale file if (removeOldEntries) { var list = new List <ZipEntry> (archive); foreach (var entry in list) { if (!validFiles.Contains(entry.FullName)) { archive.DeleteEntry(entry); } } } // Serialize index var writer = new StringWriter(); IndexSerializer.Serialize(writer, new List <SampleDesc> (index.Values)); UpdateEntry(archive, "index.xml", writer.ToString()); archive.Close(); }