コード例 #1
0
        internal static int MakeStandardFormatQuestions(StreamReader reader, StreamWriter writer, IScrVers vers)
        {
            int problemsFound = 0;
            MultilingScrBooks multilingScrBooks = new MultilingScrBooks();
            Regex             regexChapterBreak = new Regex(@"\" + s_kSectionHead + @" (?<bookAndChapter>.+ \d+)", RegexOptions.Compiled);
            Regex             regexAnswer       = new Regex(@"\" + s_kAnswerMarker + @" .+", RegexOptions.Compiled);
            Regex             regexQuestion     = new Regex(@"\d+\. +(?<question>.+[?.])( (?<versesCovered>\(\d+(-\d+)?\)))?", RegexOptions.Compiled);

            string sVersesCoveredByQuestion = null;
            string sLine;

            while ((sLine = reader.ReadLine()) != null)
            {
                sLine = sLine.Replace("  ", " ").Trim();

                if (sLine.Length == 0 || sLine.StartsWith("Back to top"))
                {
                    continue;
                }

                Match match = regexChapterBreak.Match(sLine);
                if (match.Success)
                {
                    string sBookAndChapter = match.Result("${bookAndChapter}");
                    BCVRef reference       = multilingScrBooks.ParseRefString(sBookAndChapter + ":1");
                    int    lastVerse       = vers.GetLastVerse(reference.Book, reference.Chapter);

                    sLine += ":1-" + lastVerse;
                    writer.WriteLine();
                    writer.WriteLine(sLine);
                    writer.WriteLine(s_kDetailsMarker + " Details");
                    writer.WriteLine(s_kRefMarker + " " + reference + "-" + lastVerse);
                    continue;
                }

                match = regexAnswer.Match(sLine);
                if (match.Success)
                {
                    writer.WriteLine(match + (string.IsNullOrEmpty(sVersesCoveredByQuestion) ? "" : " " + sVersesCoveredByQuestion));
                    continue;
                }

                sVersesCoveredByQuestion = null;

                match = regexQuestion.Match(sLine);
                if (match.Success)
                {
                    string sQuestion = match.Result("${question}");
                    writer.WriteLine(s_kQuestionMarker + " " + sQuestion);
                    sVersesCoveredByQuestion = match.Result("${versesCovered}");
                }
                else
                {
                    writer.WriteLine("PROBLEM: " + sLine);
                    problemsFound++;
                }
            }
            return(problemsFound);
        }
コード例 #2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ScrReferenceFilterDlg"/> class.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 internal ScrReferenceFilterDlg(IScrVers versification, BCVRef initialFromRef, BCVRef initialToRef,
                                int[] canonicalBookIds)
 {
     InitializeComponent();
     scrPsgFrom.Initialize(new BCVRef(initialFromRef), versification, canonicalBookIds);
     scrPsgTo.Initialize(new BCVRef(initialToRef), versification, canonicalBookIds);
     m_firstAvailableRef        = new BCVRef(canonicalBookIds[0], 1, 1);
     m_lastAvailableRef         = new BCVRef(canonicalBookIds.Last(), 1, 1);
     m_lastAvailableRef.Chapter = versification.GetLastChapter(m_lastAvailableRef.Book);
     m_lastAvailableRef.Verse   = versification.GetLastVerse(m_lastAvailableRef.Book, m_lastAvailableRef.Chapter);
     if (initialFromRef == m_firstAvailableRef && initialToRef == m_lastAvailableRef)
     {
         btnClearFilter.Enabled = false;
     }
 }
コード例 #3
0
ファイル: TestScrVers.cs プロジェクト: hatton/libpalaso
 public int GetLastVerse(int bookNum, int chapterNum)
 {
     return(m_vers.GetLastVerse(bookNum, chapterNum));
 }
コード例 #4
0
ファイル: BCVRef.cs プロジェクト: jwickberg/libpalaso
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Determines if the reference is valid for the given versification.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public virtual bool IsValidInVersification(IScrVers versification)
 {
     return Valid && (versification.GetLastChapter(Book) >= Chapter &&
         versification.GetLastVerse(Book, Chapter) >= Verse);
 }