Exemplo n.º 1
0
        public static bool IsValidBibleReference(BibleReference reference)
        {
            if (reference == null)
            {
                return(false);
            }
            var description = BookDescriptions.FirstOrDefault(x => x.Book == reference.Book);

            if (description == null)
            {
                return(false);
            }
            if (reference.Chapter != null)
            {
                var chapterCount = description.VerseCountsByChapter.Keys.Max();
                if (reference.Chapter < 1 || reference.Chapter > chapterCount)
                {
                    return(false);
                }
                if (reference.Verse != null)
                {
                    var verseCount = description.VerseCountsByChapter[reference.Chapter.Value];
                    if (reference.Verse < 1 || reference.Verse > verseCount)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        public object Clone()
        {
            var clone = new BibleReference
            {
                Book    = Book,
                Chapter = Chapter,
                Verse   = Verse
            };

            return(clone);
        }
Exemplo n.º 3
0
        public BibleReference Build()
        {
            if (Book == null)
            {
                throw new InvalidOperationException("Book required");
            }

            var bibleBook = BibleBookExtensions.ToBibleBook(Book);
            var reference = new BibleReference {
                Book = bibleBook, Chapter = Chapter, Verse = Verse
            };

            return(reference);
        }
Exemplo n.º 4
0
 public BibleReferenceRangeBuilder AddReference(BibleReference reference)
 {
     if (Last != null)
     {
         throw new InvalidOperationException("Too many references added. Only two references are supported.");
     }
     if (First == null)
     {
         First = reference;
     }
     else
     {
         Last = reference;
     }
     return(this);
 }