public Scripture(Scripture scripture) { Book = scripture.Book; StartChapter = scripture.StartChapter; StartVerse = scripture.StartVerse; EndChapter = scripture.EndChapter; EndVerse = scripture.EndVerse; }
public static List <Scripture> ParseScriptureFromString(this string unparsedScriptures) { var scriptures = new List <Scripture>(); var scriptureSplits = unparsedScriptures.Replace(", ", ";").Replace(",", ";").Split(';'); foreach (var scripture in scriptureSplits) { var trimmedScripture = scripture.Trim(); var cleanedScripture = trimmedScripture.Split(',')[0]; var passage = new Scripture(); if (cleanedScripture.Replace("-", string.Empty).Replace(":", string.Empty).IsNumeric()) //This is either a dangling verse, or another chapter { if (!cleanedScripture.Contains(":")) //This is just a verse coupling { var chapter = (scriptures.Last().EndChapter != null) ? scriptures.Last().EndChapter : scriptures.Last().StartChapter; if (cleanedScripture.Contains("-"))//This is a verse range { var verses = cleanedScripture.Split("-"); cleanedScripture = $"{scriptures.Last().Book} {chapter}:{verses[0]}-{chapter}:{verses[1]}"; } else { if (scriptures.Last().StartVerse == null && scriptures.Last().EndVerse == null) //Previous entry was chapter sans verses { cleanedScripture = $"{scriptures.Last().Book} {cleanedScripture}"; } else { cleanedScripture = $"{scriptures.Last().Book} {chapter}:{cleanedScripture}"; } } } } var bookName = GetBookName(cleanedScripture); passage.Book = (bookName.NullOrEmpty()) ? scriptures.Last().Book : bookName; cleanedScripture = cleanedScripture.Replace(passage.Book, "").Trim(); passage.StartChapter = GetStartChapter(cleanedScripture); passage.StartVerse = GetStartVerse(cleanedScripture); passage.EndChapter = GetEndChapter(cleanedScripture); passage.EndVerse = GetEndVerse(cleanedScripture); passage.EndChapter = (passage.EndChapter == passage.StartChapter) ? null : passage.EndChapter; scriptures.Add(passage); } return(scriptures); }