private static void TestStorageDataSerializer() { string data_string = "0123456789ABCDEF"; byte[] data_bytes = new byte[] { 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE }; Assert.IsTrue(StorageDataSerializer.ValidateHexString(data_string)); StorageDataSerializer storage_data_serializer_1 = new StorageDataSerializer(data_string); StorageDataSerializer storage_data_serializer_2 = new StorageDataSerializer(data_bytes); Assert.Equals(storage_data_serializer_1.StorageString, storage_data_serializer_2.StorageString); Assert.AreArraysEqual(storage_data_serializer_1.ReadBytes(8), storage_data_serializer_2.ReadBytes(8)); }
private void Save() { StorageDataSerializer storage_data_serializer = new StorageDataSerializer(); storage_data_serializer.WriteUInt32(0x53464553); HashSet <string> directory_paths = new HashSet <string>(); Dictionary <string, string> file_paths_contents = new Dictionary <string, string>(); GetFileSystemObjectsRecursive(RootDirectory, directory_paths, file_paths_contents); storage_data_serializer.WriteInt32(directory_paths.Count); storage_data_serializer.WriteInt32(file_paths_contents.Count); foreach (string directory_path in directory_paths) { storage_data_serializer.WriteString(directory_path); } foreach (KeyValuePair <string, string> file_path_content in file_paths_contents) { storage_data_serializer.WriteString(file_path_content.Key); storage_data_serializer.WriteString(file_path_content.Value); } Storage = storage_data_serializer.StorageString; }