private static DirectoryEntry DeserializeData(dynamic input, BackupData backupData) { DirectoryEntry dirEntry = new DirectoryEntry(); dirEntry.Name = input["n"]; foreach (var file in input["f"]) { var fileEntry = new FileEntry(); fileEntry.Name = file["n"]; fileEntry.Length = file["l"]; fileEntry.LastWriteTime = file["lwt"]; fileEntry.LatestVersion = file["v"]; fileEntry.ParentDirectory = dirEntry; dirEntry.Files.Add(fileEntry.Name, fileEntry); backupData.FileCount++; } foreach (var childDir in input["d"]) { DirectoryEntry childDirEntry = DeserializeData(childDir, backupData); childDirEntry.ParentDirectory = dirEntry; dirEntry.Directories.Add(childDirEntry.Name, childDirEntry); } backupData.DirectoryCount++; return(dirEntry); }
public static BackupData LoadDirectoryData(string path) { BackupData output = new BackupData(); string input = File.ReadAllText(path); dynamic inputData = JsonConvert.DeserializeObject(input); var data = DeserializeData(inputData, output); output.Data = data; return(output); }