public static Version.ScriptureInfo Deserialize(Stream stream) { Version.ScriptureInfo result = new Version.ScriptureInfo(); using (System.Xml.XmlReader r = System.Xml.XmlReader.Create(stream)) { while (r.Read()) { if (r.Name == "Resource") { result.Name = r.GetAttribute("name"); result.TranslationName = r.GetAttribute("tname"); result.TranslationAbbreviation = r.GetAttribute("tabbr"); while (r.Read()) { if (r.Name == "Limits") { r.Read(); var limits = new List<ChapterLimits>(); while (r.ReadToNextSibling("L")) { limits.Add(new ChapterLimits { BookNumber = int.Parse(r.GetAttribute("b")), ChapterNumber = int.Parse(r.GetAttribute("c")), StartVerseIndex = int.Parse(r.GetAttribute("s")), EndVerseIndex = int.Parse(r.GetAttribute("e")), EndVerseNumber = int.Parse(r.GetAttribute("v")) }); } result.ChapterLimits = limits.ToArray(); } else if (r.Name == "Books") { r.Read(); var books = new List<ScriptureBook>(); while (r.ReadToNextSibling("B")) { string o = r.GetAttribute("o"); var book = new ScriptureBook { Name = r.GetAttribute("n"), Number = int.Parse(r.GetAttribute("i")), ShortAbbr = r.GetAttribute("s"), LongAbbr = r.GetAttribute("l"), Ordinal = string.IsNullOrEmpty(o) ? -1 : int.Parse(o) }; var abbrs = new List<string>(); r.Read(); while (r.ReadToNextSibling("A")) { abbrs.Add(r.ReadInnerXml()); } book.Abbreviations = abbrs.ToArray(); books.Add(book); } result.Books = books.ToArray(); } } } } } return result; }
public static Version.ScriptureInfo Deserialize(Stream stream) { Version.ScriptureInfo result = new Version.ScriptureInfo(); using (System.Xml.XmlReader r = System.Xml.XmlReader.Create(stream)) { while (r.Read()) { if (r.Name == "Resource") { result.Name = r.GetAttribute("name"); result.TranslationName = r.GetAttribute("tname"); result.TranslationAbbreviation = r.GetAttribute("tabbr"); while (r.Read()) { if (r.Name == "Limits") { r.Read(); var limits = new List <ChapterLimits>(); while (r.ReadToNextSibling("L")) { limits.Add(new ChapterLimits { BookNumber = int.Parse(r.GetAttribute("b")), ChapterNumber = int.Parse(r.GetAttribute("c")), StartVerseIndex = int.Parse(r.GetAttribute("s")), EndVerseIndex = int.Parse(r.GetAttribute("e")), EndVerseNumber = int.Parse(r.GetAttribute("v")) }); } result.ChapterLimits = limits.ToArray(); } else if (r.Name == "Books") { r.Read(); var books = new List <ScriptureBook>(); while (r.ReadToNextSibling("B")) { string o = r.GetAttribute("o"); var book = new ScriptureBook { Name = r.GetAttribute("n"), Number = int.Parse(r.GetAttribute("i")), ShortAbbr = r.GetAttribute("s"), LongAbbr = r.GetAttribute("l"), Ordinal = string.IsNullOrEmpty(o) ? -1 : int.Parse(o) }; var abbrs = new List <string>(); r.Read(); while (r.ReadToNextSibling("A")) { abbrs.Add(r.ReadInnerXml()); } book.Abbreviations = abbrs.ToArray(); books.Add(book); } result.Books = books.ToArray(); } } } } } return(result); }