public PageEntry AddPage(DocumentEntry document, string content) { var page = _entryFactory.CreatePage(document, content); document.Pages.Add(page); return(page); }
public SolutionEntry Deserialize(string path) { string solutionName = System.IO.Path.GetFileNameWithoutExtension(path); var dict = new Dictionary <string, List <Tuple <string, string> > >(); var solution = new SolutionEntry() { Name = solutionName, Documents = new ObservableCollection <DocumentEntry>() }; using (var zip = ZipFile.Open(path, ZipArchiveMode.Read)) { foreach (var entry in zip.Entries) { var e = entry.FullName.Split(entryNameSeparator); if (e.Length == 1) { string key = e[0]; if (!dict.ContainsKey(key)) { dict.Add(key, new List <Tuple <string, string> >()); } } else if (e.Length == 2) { string key = e[0]; string data = e[1]; string content = null; using (var reader = new StreamReader(entry.Open())) { content = reader.ReadToEnd(); } if (!dict.ContainsKey(key)) { dict.Add(key, new List <Tuple <string, string> >()); } dict[key].Add(new Tuple <string, string>(data, content)); } } } foreach (var item in dict) { var document = _entryFactory.CreateDocument(solution, item.Key); solution.Documents.Add(document); foreach (var tuple in item.Value) { var page = _entryFactory.CreatePage(document, tuple.Item2, tuple.Item1); document.Pages.Add(page); } } return(solution); }