}//public static string ToString() /// <summary>The URI Crosswalk HTML.</summary> public static StringBuilder URICrosswalkHtml ( ScriptureReferenceBookChapterVersePrePost scriptureReferenceBookChapterVersePrePost ) { StringBuilder sb = new StringBuilder( scriptureReferenceBookChapterVersePrePost.preBookTitle ); sb.Append( URICrosswalkDelimiterBookTitleChapter ); sb.Append( scriptureReferenceBookChapterVersePrePost.preChapter ); switch ( scriptureReferenceBookChapterVersePrePost.sonInLaw ) { case SonInLawPreBookTitlePreChapter: break; case SonInLawPreBookTitlePreChapterPreVerse: sb.Append( URICrosswalkDelimiterChapterVerse ); sb.Append( scriptureReferenceBookChapterVersePrePost.preVerse ); break; case SonInLawPreBookTitlePreChapterPreVersePostVerse: sb.Append( URICrosswalkDelimiterChapterVerse ); sb.Append( scriptureReferenceBookChapterVersePrePost.preVerse ); sb.Append( URICrosswalkDelimiterPrePost ); sb.Append( scriptureReferenceBookChapterVersePrePost.postVerse ); break; case SonInLawPreBookTitlePreChapterPreVersePostChapterPostVerse: sb.Append( URICrosswalkDelimiterChapterVerse ); sb.Append( scriptureReferenceBookChapterVersePrePost.preVerse ); sb.Append( URICrosswalkDelimiterPrePost ); sb.Append( scriptureReferenceBookChapterVersePrePost.postChapter ); sb.Append( URICrosswalkDelimiterChapterVerse ); sb.Append( scriptureReferenceBookChapterVersePrePost.postVerse ); break; case SonInLawPreBookTitlePreChapterPreVersePostBookTitlePostChapterPostVerse: sb.Append( URICrosswalkDelimiterChapterVerse ); sb.Append( scriptureReferenceBookChapterVersePrePost.preVerse ); sb.Append( URICrosswalkDelimiterPrePost ); sb.Append( scriptureReferenceBookChapterVersePrePost.postBookTitle ); sb.Append( URICrosswalkDelimiterBookTitleChapter ); sb.Append( scriptureReferenceBookChapterVersePrePost.postChapter ); sb.Append( URICrosswalkDelimiterChapterVerse ); sb.Append( scriptureReferenceBookChapterVersePrePost.postVerse ); break; default: sb = new StringBuilder(); break; }//switch ( sonInLaw ) return ( sb ); }//public static StringBuilder URICrosswalkHtml( ScriptureReferenceBookChapterVersePrePost scriptureReferenceBookChapterVersePrePost )
///<summary>The entry point for the application.</summary> ///<param name="argv"> /// A list of scripture reference arguments. for example: /// "Genesis 1", "Genesis 2:3", "Genesis 4:5-6", "Genesis 24:5-27:46" ///</param> public static void Main ( string[] argv ) { int rowCount = -1; string databaseConnectionString = DatabaseConnectionString; string exceptionMessage = null; string[][] scriptureReferenceArray = null; StringBuilder scriptureReferenceText = null; StringBuilder uriCrosswalkHtml = null; StringBuilder uriCrosswalkXml = null; StringBuilder[] scriptureReferenceBookChapterVersePrePostCondition = null; StringBuilder[] scriptureReferenceBookChapterVersePrePostSelect = null; StringBuilder scriptureReferenceBookChapterVersePrePostQuery = null; IDataReader iDataReader = null; ScriptureReferenceBookChapterVersePrePost[] scriptureReferenceBookChapterVersePrePost = null; ConfigurationXml( FilenameConfigurationXml, ref exceptionMessage, ref databaseConnectionString ); ScriptureReferenceParser ( argv, databaseConnectionString, ref exceptionMessage, ref scriptureReferenceBookChapterVersePrePost, ref scriptureReferenceArray, ref uriCrosswalkHtml, ref uriCrosswalkXml ); ScriptureReferenceQuery ( databaseConnectionString, ref exceptionMessage, ref scriptureReferenceBookChapterVersePrePost, ref iDataReader, ref rowCount, ref scriptureReferenceText, ref scriptureReferenceBookChapterVersePrePostCondition, ref scriptureReferenceBookChapterVersePrePostSelect, ref scriptureReferenceBookChapterVersePrePostQuery ); ScriptureReferenceBookChapterVersePrePost.XPathCondition ( BibleXmlFilename, ref exceptionMessage, scriptureReferenceBookChapterVersePrePost ); }//public static void Main
}//public static void ScriptureReferenceParser ///<summary>Scripture Reference Query.</summary> ///<param name="databaseConnectionString">The database connection string.</param> ///<param name="exceptionMessage">The exception message.</param> ///<param name="scriptureReferenceText">The scripture reference text.</param> ///<param name="iDataReader">The data reader.</param> ///<param name="rowCount">Returns the number of rows affected by the last statement.</param> ///<param name="scriptureReferenceBookChapterVersePrePost">The scripture reference book, chapter, verse, pre and post.</param> ///<param name="scriptureReferenceBookChapterVersePrePostCondition">The condition for the scripture reference book, chapter, verse, pre and post.</param> ///<param name="scriptureReferenceBookChapterVersePrePostSelect">The SQL statement for each scripture reference book, chapter, verse, pre and post.</param> ///<param name="scriptureReferenceBookChapterVersePrePostQuery">The SQL statement for the scripture reference book, chapter, verse, pre and post.</param> ///<example> ///<code> ///int rowCount = 0; ///string exceptionMessage = null; ///StringBuilder[] scriptureReferenceBookChapterVersePrePost = null; ///StringBuilder[] scriptureReferenceBookChapterVersePrePostCondition = null; ///StringBuilder[] scriptureReferenceBookChapterVersePrePostSelect = null; ///StringBuilder scriptureReferenceBookChapterVersePrePostQuery = null; ///ScriptureReferenceQuery /// ( /// DatabaseConnectionString, /// ref iDataReader, /// ref rowCount, /// ref scriptureReferenceText, /// ref exceptionMessage, /// ref scriptureReferenceBookChapterVersePrePostCondition, /// ref scriptureReferenceBookChapterVersePrePostSelect, /// ref scriptureReferenceBookChapterVersePrePostQuery /// ); ///</code> ///</example> public static void ScriptureReferenceQuery ( string databaseConnectionString, ref string exceptionMessage, ref ScriptureReferenceBookChapterVersePrePost[] scriptureReferenceBookChapterVersePrePost, ref IDataReader iDataReader, ref int rowCount, ref StringBuilder scriptureReferenceText, ref StringBuilder[] scriptureReferenceBookChapterVersePrePostCondition, ref StringBuilder[] scriptureReferenceBookChapterVersePrePostSelect, ref StringBuilder scriptureReferenceBookChapterVersePrePostQuery ) { exceptionMessage = null; ScriptureReferenceBookChapterVersePrePost.SQLStatementCondition ( databaseConnectionString, ref exceptionMessage, scriptureReferenceBookChapterVersePrePost, ref scriptureReferenceBookChapterVersePrePostCondition, ref scriptureReferenceBookChapterVersePrePostSelect, ref scriptureReferenceBookChapterVersePrePostQuery );//ScriptureReferenceBookChapterVersePrePost.SQLStatementCondition() if ( exceptionMessage != null ) { return; }//if ( exceptionMessage != null ) ScriptureReferenceBookChapterVersePrePost.SQLStatementQuery ( databaseConnectionString, ref exceptionMessage, ref scriptureReferenceBookChapterVersePrePost, ref iDataReader, ref rowCount, ref scriptureReferenceText, scriptureReferenceBookChapterVersePrePostQuery, CommandType.Text );//ScriptureReferenceBookChapterVersePrePost.SQLStatementQuery() }//ScriptureReferenceQuery()
}//public static void Main ///<summary>Scripture Reference Parser.</summary> ///<param name="scriptureReference">The scripture reference.</param> ///<param name="databaseConnectionString">The database connection string.</param> ///<param name="exceptionMessage">The exception message.</param> ///<param name="scriptureReferenceBookChapterVersePrePost">The scripture reference book, chapter, verse, pre and post.</param> ///<param name="scriptureReferenceArray">The scripture reference subset.</param> ///<param name="uriCrosswalkHtml">The URI for the Crosswalk HTML.</param> ///<param name="uriCrosswalkXml">The URI for the Crosswalk XML.</param> ///<example> ///<code> ///string exceptionMessage = null; ///string[] scriptureReference = new string[] /// { /// "Genesis 1", /// "Genesis 2:3", /// "Genesis 4:5-6", /// "Genesis 24:5-27:46" /// }; ///ScriptureReferenceBookChapterVersePrePost[] scriptureReferenceBookChapterVersePrePost = null; ///string[][] scriptureReferenceArray = null; ///StringBuilder uriCrosswalkHtml = null; ///StringBuilder uriCrosswalkXml = null; ///ScriptureReferenceParser /// ( /// scriptureReference, /// DatabaseConnectionString, /// ref exceptionMessage, /// ref scriptureReferenceArray, /// ref uriCrosswalkHtml, /// ref uriCrosswalkXml, /// ); ///</code> ///</example> public static void ScriptureReferenceParser ( string[] scriptureReference, string databaseConnectionString, ref string exceptionMessage, ref ScriptureReferenceBookChapterVersePrePost[] scriptureReferenceBookChapterVersePrePost, ref string[][] scriptureReferenceArray, ref StringBuilder uriCrosswalkHtml, ref StringBuilder uriCrosswalkXml ) { bool scriptureReferenceSubsetPostIncludesBook = false; int scriptureReferenceSubsetPrePostBookChapterVerseCount = 0; int scriptureReferenceSubsetCount = 0; int scriptureReferenceSubsetPrePostBookChapterZeroBasedIndex = -1; int scriptureReferenceSubsetPrePostBookChapterZeroBasedIndexLetter = -1; int scriptureReferenceSubsetPrePostBookChapterZeroBasedLength = -1; int scriptureReferenceSubsetTotal = 0; string[] scriptureReferenceBookChapterVerse = null; string[] scriptureReferenceCurrentSubset = null; string[] scriptureReferencePrePost = null; exceptionMessage = null; foreach ( string scriptureReferenceCurrent in scriptureReference ) { ++scriptureReferenceSubsetTotal; for ( int scriptureReferenceCurrentPosition = 0; scriptureReferenceCurrentPosition < scriptureReferenceCurrent.Length; ++scriptureReferenceCurrentPosition ) { if ( scriptureReferenceCurrent[scriptureReferenceCurrentPosition] == ',' || scriptureReferenceCurrent[scriptureReferenceCurrentPosition] == ';') { ++scriptureReferenceSubsetTotal; }//if ( scriptureReferenceCurrent[scriptureReferenceCurrentPosition] == ',' || scriptureReferenceCurrent[scriptureReferenceCurrentPosition] == ';') }//for ( int scriptureReferenceCurrentPosition = 0; scriptureReferenceCurrentPosition < scriptureReferenceCurrent.Length; ++scriptureReferenceCurrentPosition) }//foreach ( string scriptureReferenceCurrent in scriptureReference ) scriptureReferenceArray = new string[scriptureReferenceSubsetTotal][]; for ( scriptureReferenceSubsetCount = 0; scriptureReferenceSubsetCount < scriptureReferenceSubsetTotal; ++scriptureReferenceSubsetCount) { scriptureReferenceArray[scriptureReferenceSubsetCount] = new string[ScriptureReferenceSubsetElementTotal]; } scriptureReferenceBookChapterVersePrePost = new ScriptureReferenceBookChapterVersePrePost[scriptureReferenceSubsetTotal]; scriptureReferenceSubsetCount = -1; foreach ( string scriptureReferenceCurrent in scriptureReference ) { scriptureReferenceCurrentSubset = scriptureReferenceCurrent.Split(DelimiterCharScriptureReferenceSubset); for( int scriptureReferenceCurrentSubsetCount = 0; scriptureReferenceCurrentSubsetCount < scriptureReferenceCurrentSubset.Length; ++scriptureReferenceCurrentSubsetCount ) { ++scriptureReferenceSubsetCount; scriptureReferenceCurrentSubset[scriptureReferenceCurrentSubsetCount] = scriptureReferenceCurrentSubset[scriptureReferenceCurrentSubsetCount].Trim(); scriptureReferencePrePost = scriptureReferenceCurrentSubset[scriptureReferenceCurrentSubsetCount].Split(DelimiterCharScriptureReferencePrePost); scriptureReferenceSubsetPostIncludesBook = false; for( int scriptureReferencePrePostCount = 0; scriptureReferencePrePostCount < scriptureReferencePrePost.Length; ++scriptureReferencePrePostCount ) { scriptureReferenceBookChapterVerse = scriptureReferencePrePost[scriptureReferencePrePostCount].Split(DelimiterCharScriptureReferenceChapterVerse); for( int scriptureReferenceBookChapterVerseCount = 0; scriptureReferenceBookChapterVerseCount < scriptureReferenceBookChapterVerse.Length; ++scriptureReferenceBookChapterVerseCount ) { scriptureReferenceBookChapterVerse[scriptureReferenceSubsetPrePostBookChapterVerseCount] = scriptureReferenceBookChapterVerse[scriptureReferenceSubsetPrePostBookChapterVerseCount].Trim(); switch ( scriptureReferenceBookChapterVerseCount ) { case ScriptureReferenceSubsetPrePostBookChapter: scriptureReferenceSubsetPrePostBookChapterZeroBasedLength = scriptureReferenceBookChapterVerse[scriptureReferenceSubsetPrePostBookChapterVerseCount].Length - 1; scriptureReferenceSubsetPrePostBookChapterZeroBasedIndexLetter = -1; for ( scriptureReferenceSubsetPrePostBookChapterZeroBasedIndex = scriptureReferenceSubsetPrePostBookChapterZeroBasedLength; scriptureReferenceSubsetPrePostBookChapterZeroBasedIndex >= 0; scriptureReferenceSubsetPrePostBookChapterZeroBasedIndex-- ) { if ( char.IsLetter( scriptureReferenceBookChapterVerse[scriptureReferenceBookChapterVerseCount][scriptureReferenceSubsetPrePostBookChapterZeroBasedIndex] ) ) { scriptureReferenceSubsetPrePostBookChapterZeroBasedIndexLetter = scriptureReferenceSubsetPrePostBookChapterZeroBasedIndex; if ( scriptureReferencePrePostCount == ScriptureReferenceSubsetPost ) { scriptureReferenceSubsetPostIncludesBook = true; }//if ( scriptureReferencePrePostCount == ScriptureReferenceSubsetPost ) break; }//if ( char.IsLetter( scriptureReferenceBookChapterVerse[scriptureReferenceSubsetPrePostBookChapterVerseCount][scriptureReferenceSubsetPrePostBookChapterZeroBasedIndex] ) }//for ( scriptureReferenceSubsetPrePostBookChapterZeroBasedIndex = scriptureReferenceSubsetPrePostBookChapterZeroBasedLength; scriptureReferenceSubsetPrePostBookChapterZeroBasedIndex > 0; -- scriptureReferenceSubsetPrePostBookChapterZeroBasedIndex ) if ( scriptureReferenceSubsetPrePostBookChapterZeroBasedLength == scriptureReferenceSubsetPrePostBookChapterZeroBasedIndexLetter ) { scriptureReferenceArray[scriptureReferenceSubsetCount][3 * scriptureReferencePrePostCount + ScriptureReferenceBook] = scriptureReferenceBookChapterVerse[scriptureReferenceBookChapterVerseCount]; scriptureReferenceArray[scriptureReferenceSubsetCount][3 * scriptureReferencePrePostCount + ScriptureReferenceChapter] = null; }//if ( scriptureReferenceSubsetPrePostBookChapterZeroBasedLength == scriptureReferenceSubsetPrePostBookChapterZeroBasedIndexLetter + 1 ) else if ( scriptureReferenceSubsetPrePostBookChapterZeroBasedIndexLetter > -1 ) { scriptureReferenceArray[scriptureReferenceSubsetCount][3 * scriptureReferencePrePostCount + ScriptureReferenceBook] = scriptureReferenceBookChapterVerse[scriptureReferenceBookChapterVerseCount].Substring( 0, scriptureReferenceSubsetPrePostBookChapterZeroBasedIndexLetter + 1).Trim(); scriptureReferenceArray[scriptureReferenceSubsetCount][3 * scriptureReferencePrePostCount + ScriptureReferenceChapter] = scriptureReferenceBookChapterVerse[scriptureReferenceBookChapterVerseCount].Substring( scriptureReferenceSubsetPrePostBookChapterZeroBasedIndexLetter + 1 ).Trim(); }//else if ( scriptureReferenceSubsetPrePostBookChapterZeroBasedIndexLetter >= -1 ) else { scriptureReferenceArray[scriptureReferenceSubsetCount][3 * scriptureReferencePrePostCount + ScriptureReferenceBook] = null; scriptureReferenceArray[scriptureReferenceSubsetCount][3 * scriptureReferencePrePostCount + ScriptureReferenceChapter] = scriptureReferenceBookChapterVerse[scriptureReferenceBookChapterVerseCount]; } break; case ScriptureReferenceSubsetPrePostVerse: scriptureReferenceArray[scriptureReferenceSubsetCount][3 * scriptureReferencePrePostCount + ScriptureReferenceVerse] = scriptureReferenceBookChapterVerse[scriptureReferenceBookChapterVerseCount]; break; }//switch ( scriptureReferenceBookChapterVerseCount ) }//for( int scriptureReferenceBookChapterVerseCount = 0; scriptureReferenceBookChapterVerse < scriptureReferenceBookChapterVerse.Length; ++scriptureReferenceBookChapterVerseCount ) switch ( scriptureReferencePrePostCount ) { case ScriptureReferenceSubsetPrePostPost: if ( scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostBook] != null && scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostChapter] != null && scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostVerse] != null ) { } else if ( scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePreChapter] != null && scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePreVerse] == null && scriptureReferenceSubsetPostIncludesBook == false && scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostChapter] == null && scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostVerse] == null ) { scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostChapter] = scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostBook]; scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostBook] = null; } else if ( scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePreChapter] != null && scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePreVerse] != null && scriptureReferenceSubsetPostIncludesBook == false && scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostChapter] == null && scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostVerse] == null ) { scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostVerse] = scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostBook]; scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostBook] = null; } else if ( scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePreChapter] != null && scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePreVerse] != null && scriptureReferenceSubsetPostIncludesBook == false && scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostChapter] != null && scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostVerse] == null ) { scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostVerse] = scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostChapter]; scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostChapter] = scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostBook]; scriptureReferenceArray[scriptureReferenceSubsetCount][ScriptureReferencePostBook] = null; } break; }//switch ( scriptureReferencePrePostCount ) }//for( int scriptureReferencePrePostCount = 0; scriptureReferencePrePostCount < scriptureReferencePrePost.Length; ++scriptureReferencePrePostCount ) /* #if (DEBUG) System.Console.WriteLine ( "ScriptureReferenceBookChapterVersePost [{0}]: {1}.", scriptureReferenceSubsetCount, UtilityCollection.ToString( scriptureReferenceArray[scriptureReferenceSubsetCount] ) ); #endif */ scriptureReferenceBookChapterVersePrePost[ scriptureReferenceSubsetCount ] = new ScriptureReferenceBookChapterVersePrePost( scriptureReferenceArray[scriptureReferenceSubsetCount] ); #if (DEBUG) System.Console.WriteLine ( "ScriptureReferenceBookChapterVersePost [{0}]: {1} | {2} | SonInLaw: {3}.", scriptureReferenceSubsetCount, scriptureReferenceBookChapterVersePrePost[ scriptureReferenceSubsetCount ], UtilityCollection.ToString( scriptureReferenceArray[scriptureReferenceSubsetCount] ), scriptureReferenceBookChapterVersePrePost[ scriptureReferenceSubsetCount ].SonInLaw ); #endif }//for( int scriptureReferenceSubsetCount = 0; scriptureReferenceSubsetCount < scriptureReferenceArray.Length; ++scriptureReferenceSubsetCount ) }//foreach ( string scriptureReferenceCurrent in scriptureReference ) uriCrosswalkHtml = ScriptureReferenceBookChapterVersePrePost.URICrosswalkHtml(scriptureReferenceBookChapterVersePrePost); uriCrosswalkXml = ScriptureReferenceBookChapterVersePrePost.URICrosswalkXml(uriCrosswalkHtml); #if (DEBUG) System.Console.WriteLine("Scripture Reference URI Crosswalk (HTML): {0}", uriCrosswalkHtml); System.Console.WriteLine("Scripture Reference URI Crosswalk (XML): {0}", uriCrosswalkXml); #endif }//public static void ScriptureReferenceParser