public async Task LoadXml() { if (IsLoaded) return; IFolder rootfolder = FileSystem.Current.LocalStorage; Debug.WriteLine (rootfolder.Path); IFile file = await rootfolder.GetFileAsync ("roget15aHierarchy.xml"); using (TextReader reader = new StreamReader(await file.OpenAsync(FileAccess.Read))) { XmlSerializer serializer = new XmlSerializer(typeof(RogetHierarchy)); hierarchy = (RogetHierarchy)serializer.Deserialize(reader); // HACK: makes Divisions synonymous with Sections, makes navigation easier foreach (var h in hierarchy.Classes) { foreach (RogetDivision d in h.Divisions) { h.Sections.Add(new RogetSection{Name=d.Name, Sections = d.Sections}); } } } Classes = hierarchy.Classes; file = await rootfolder.GetFileAsync ("roget15aCategories.xml"); using (TextReader reader = new StreamReader(await file.OpenAsync(FileAccess.Read))) { XmlSerializer serializer = new XmlSerializer(typeof(RogetCategories)); Categories = (RogetCategories)serializer.Deserialize(reader); } IsLoaded = true; return; }
public async Task LoadXml() { if (IsLoaded) { return; } IFolder rootfolder = FileSystem.Current.LocalStorage; Debug.WriteLine(rootfolder.Path); IFile file = await rootfolder.GetFileAsync("roget15aHierarchy.xml"); using (TextReader reader = new StreamReader(await file.OpenAsync(FileAccess.Read))) { XmlSerializer serializer = new XmlSerializer(typeof(RogetHierarchy)); hierarchy = (RogetHierarchy)serializer.Deserialize(reader); // HACK: makes Divisions synonymous with Sections, makes navigation easier foreach (var h in hierarchy.Classes) { foreach (RogetDivision d in h.Divisions) { h.Sections.Add(new RogetSection { Name = d.Name, Sections = d.Sections }); } } } Classes = hierarchy.Classes; file = await rootfolder.GetFileAsync("roget15aCategories.xml"); using (TextReader reader = new StreamReader(await file.OpenAsync(FileAccess.Read))) { XmlSerializer serializer = new XmlSerializer(typeof(RogetCategories)); Categories = (RogetCategories)serializer.Deserialize(reader); } IsLoaded = true; return; }