Exemple #1
0
        }   // public string [ ] Split ( )


        /// <summary>
        /// Format the properties into a comma-delimited string, which may be
        /// used as is or processed by the Split method on this instance.
        /// 
        /// Please see the remarks for essential information about this string.
        /// </summary>
        /// <returns>
        /// Please see the remarks for essential information about this string.
        /// </returns>
        /// <remarks>
        /// The standard string.Split method cannot split this string correctly,
        /// because it treats commas embedded in its strings as delimiters, thus
        /// splitting the string into too many pieces, and at the wrong places.
        /// 
        /// Use the Split method on this instance, which employs a robust CSV
        /// parsing engine that splits it correctly.
        /// </remarks>
        public override string ToString ( )
        {
            ASCIICharacterDisplayInfo [ ] asciiCharTbl = ASCII_Character_Display_Table.GetTheSingleInstance ( ).AllASCIICharacters;

            StringBuilder sbTheBadChar = new StringBuilder ( );

            sbTheBadChar.Append ( asciiCharTbl [ ( uint ) _chrBad ].DisplayText );

            string strTheMessage;

            if ( _strMessage.IndexOf ( FIELD_DELIMITER ) > FormatItem.INVALID_OFFSET )
                strTheMessage = string.Concat ( new object [ ]
                {
                    COMMA_GUARD ,
                    _strMessage ,
                    COMMA_GUARD
                } );
            else
                strTheMessage = _strMessage;

            return string.Format (
                Properties.Resources.ERRMSG_FORMAT_STRING_ERROR_TPL ,   // Message template
                new object [ ]
                {
                    _intOffset ,                                        // Format Item 0 = Offset
                    sbTheBadChar ,                                      // Format Item 1 = Character
                    _enmState ,                                         // Format Item 2 = Parser State
                    strTheMessage                                       // Format Item 3 = Message
                } );
        }   // public override string ToString
		internal static void ASCII_Table_Gen ( )
		{
			Console.WriteLine (
				Properties.Resources.IDS_ASCII_TABLE_PREAMBLE ,					// Print this message above both tables.
				Environment.NewLine );                                          // Format Item 0 = Embedded Newline

			Console.WriteLine (
				Properties.Resources.IDS_ASCII_TABLE_CHARACTER_PROPERTIES ,		// Print this message above the first table.
				Environment.NewLine );                                          // Format Item 0 = Embedded Newline
			string strDetailFormatTemplate = Properties.Resources.IDS_ASCII_CHARACTER_INFO;

			for ( int intCharacterIndex = ARRAY_FIRST_ELEMENT ;
				      intCharacterIndex <= byte.MaxValue ;
					  intCharacterIndex++ )
			{
				Console.WriteLine (
					strDetailFormatTemplate ,                                   // Format control string
					intCharacterIndex ,                                         // Format Item 0: Character index {0}
					ASCIICharacterDisplayInfo.DisplayCharacterInfo (            // Format Item 1: : {1}
						( char ) intCharacterIndex ) );                         // Cast the integer to its char equivalent.
			}   // for ( int intCharacterIndex = ARRAY_FIRST_ELEMENT ; intCharacterIndex <= byte.MaxValue ; intCharacterIndex++ )

			Console.WriteLine (
				Properties.Resources.IDS_ASCII_TABLE_ENUMERATION ,              // Print this message between the two tables.
				Environment.NewLine );                                          // Format Item 0 = Embedded Newline

			ASCII_Character_Display_Table asciiShowMan = ASCII_Character_Display_Table.GetTheSingleInstance ( );
			strDetailFormatTemplate = Properties.Resources.IDS_ASCII_TABLE_ITEM;

			foreach ( ASCIICharacterDisplayInfo asciiInfo in asciiShowMan.AllASCIICharacters )
			{
				Console.WriteLine (
					strDetailFormatTemplate ,                                   // Format control string, read above the loop
					new object [ ]
					{
						asciiInfo.CodeAsDecimal ,								// Format Item 0 = Decimal code of character
						asciiInfo.CodeAsHexadecimal ,							// Format Item 1 = Hexadecimal representation of character code
						asciiInfo.DisplayText ,									// Format Item 2 = Character as displayed, or substitute for characters that won't print anything usable
						string.IsNullOrEmpty ( asciiInfo.Comment )				// Format Item 3 = Comment, if present, else nothing			
							? string.Empty										//		Since there is no comment, show nothing.
							: string.Concat (									//		Comments get wrapped in parentheses, and separated by a space.
								" (" ,											//		Leading space and left parenthesis
								asciiInfo.Comment ,								//		Comment from XML document
								")" )											//		Right parenthesis
					} );
			}   // foreach ( ASCIICharacterDisplayInfo asciiInfo in asciiShowMan.AllASCIICharacters )
		}	// ASCII_Table_Gen
Exemple #3
0
		internal static void ASCII_Table_Gen ( )
		{
			Console.WriteLine (
				Properties.Resources.IDS_ASCII_TABLE_PREAMBLE ,					// Print this message above the table.
				Environment.NewLine );											// Format Item 0 = Embedded Newline
			ASCII_Character_Display_Table asciiShowMan = ASCII_Character_Display_Table.GetTheSingleInstance ( );
			string strDetailFormatTemplate = Properties.Resources.IDS_ASCII_TABLE_ITEM;
			foreach ( ASCIICharacterDisplayInfo asciiInfo in asciiShowMan.AllASCIICharacters )
				Console.WriteLine (
					strDetailFormatTemplate ,									// Format control string, read above the loop
					new object [ ]
					{
						asciiInfo.CodeAsDecimal ,								// Format Item 0 = Decimal code of character
						asciiInfo.CodeAsHexadecimal ,							// Format Item 1 = Hexadecimal representation of character code
						asciiInfo.DisplayText ,									// Format Item 2 = Character as displayed, or substitute for characters that won't print anything usable
						string.IsNullOrEmpty ( asciiInfo.Comment )				// Format Item 3 = Comment, if present, else nothing			
							? string.Empty										//		Since there is no comment, show nothing.
							: string.Concat (									//		Comments get wrapped in parentheses, and separated by a space.
								" (" ,											//		Leading space and left parenthesis
								asciiInfo.Comment ,								//		Comment from XML document
								")" )											//		Right parenthesis
					} );
		}	// ASCII_Table_Gen
		internal static void ASCII_Table_Gen ( )
		{
			StreamWriter swAsciiTableLists = null;

			try
			{
				swAsciiTableLists = GetAsciiTableListFileHandle ( );

				Console.WriteLine (
					Properties.Resources.IDS_ASCII_TABLE_PREAMBLE ,             // Print this message above both tables.
					Environment.NewLine );                                      // Format Item 0 = Embedded Newline
				swAsciiTableLists.WriteLine (
					Properties.Resources.IDS_ASCII_TABLE_PREAMBLE ,             // Print this message above both tables.
					Environment.NewLine );                                      // Format Item 0 = Embedded Newline

				Console.WriteLine (
					Properties.Resources.IDS_ASCII_TABLE_CHARACTER_PROPERTIES , // Print this message above the first table.
					Environment.NewLine );                                      // Format Item 0 = Embedded Newline
				swAsciiTableLists.WriteLine (
					Properties.Resources.IDS_ASCII_TABLE_CHARACTER_PROPERTIES , // Print this message above the first table.
					Environment.NewLine );                                      // Format Item 0 = Embedded Newline

				string strDetailFormatTemplate = Properties.Resources.IDS_ASCII_CHARACTER_INFO;
				string strDisplayInfoTemplate = Properties.Resources.MSG_ASCII_TABLE_DETAIL;

				try
				{
					ASCII_Character_Display_Table aSCII_Character_Display_Table = ASCII_Character_Display_Table.GetTheSingleInstance ( );

					for ( int intJ = ArrayInfo.ARRAY_FIRST_ELEMENT ;
							  intJ < aSCII_Character_Display_Table.AllASCIICharacters.Length ;
							  intJ++ )
					{
						ASCIICharacterDisplayInfo displayInfo = aSCII_Character_Display_Table.AllASCIICharacters [ intJ ];
						Console.WriteLine (
							strDisplayInfoTemplate ,							// Format Control String
							intJ ,                                              // Format Item 0: Character {0:-3}: Numerical
							displayInfo.CodeAsDecimal ,                         // Format Item 1: Numerical Value = {1,3} (
							displayInfo.CodeAsHexadecimal ,                     // Format Item 2: ({2} hex),
							displayInfo.DisplayText ,                           // Format Item 3: Display Value = {3}
							displayInfo.HTMLName );                             // Format Item 4: HTML Entity = {4}
						swAsciiTableLists.WriteLine (
							strDisplayInfoTemplate ,                            // Format Control String
							intJ ,                                              // Format Item 0: Character {0:-3}: Numerical
							displayInfo.CodeAsDecimal ,                         // Format Item 1: Numerical Value = {1,3} (
							displayInfo.CodeAsHexadecimal ,                     // Format Item 2: ({2} hex),
							displayInfo.DisplayText ,                           // Format Item 3: Display Value = {3}
							displayInfo.HTMLName );                             // Format Item 4: HTML Entity = {4}
					}   // for ( int intJ = ArrayInfo.ARRAY_FIRST_ELEMENT ; intJ < aSCII_Character_Display_Table.AllASCIICharacters.Length ; intJ++ )
				}
				catch ( Exception exAll )
				{
					Program.s_smTheApp.AppExceptionLogger.ReportException ( exAll );
				}

				Console.WriteLine (
					Properties.Resources.IDS_ASCII_TABLE_ENUMERATION ,          // Print this message between the two tables.
					Environment.NewLine );                                      // Format Item 0 = Embedded Newline
				swAsciiTableLists.WriteLine (
					Properties.Resources.IDS_ASCII_TABLE_ENUMERATION ,          // Print this message between the two tables.
					Environment.NewLine );                                      // Format Item 0 = Embedded Newline

				ASCII_Character_Display_Table asciiShowMan = ASCII_Character_Display_Table.GetTheSingleInstance ( );
				strDetailFormatTemplate = Properties.Resources.IDS_ASCII_TABLE_ITEM;

				foreach ( ASCIICharacterDisplayInfo asciiInfo
						  in asciiShowMan.AllASCIICharacters )
				{
					Console.WriteLine (
						strDetailFormatTemplate ,                               // Format control string, read above the loop
						new object [ ]
						{
							asciiInfo.CodeAsDecimal ,							// Format Item 0: Character {0} (
							asciiInfo.CodeAsHexadecimal ,						// Format Item 1: ({1}): Display
							asciiInfo.URLEncoding ,								// Format Item 2: URL Encoding = {2}
							asciiInfo.DisplayText ,								// Format Item 3: Display Value = {3}
							string.IsNullOrEmpty ( asciiInfo.Comment )			// Format Item 4: Comment, if present, else nothing
								? string.Empty									//		Since there is no comment, show nothing.
								: string.Concat (								//		Comments get wrapped in parentheses and separated by a space.
									SpecialCharacters.SPACE_CHAR ,				//		Leading space 
									SpecialCharacters.PARENTHESIS_LEFT ,		//      and left parenthesis
									asciiInfo.Comment ,							//		Comment from document
									SpecialCharacters.PARENTHESIS_RIGHT )       //		Right parenthesis
						} );
					swAsciiTableLists.WriteLine (
						strDetailFormatTemplate ,                               // Format control string, read above the loop
						new object [ ]
						{
							asciiInfo.CodeAsDecimal ,							// Format Item 0: Character {0} (
							asciiInfo.CodeAsHexadecimal ,						// Format Item 1: ({1}): Display
							asciiInfo.URLEncoding ,								// Format Item 2: URL Encoding = {2}
							asciiInfo.DisplayText ,								// Format Item 3: Display Value = {3}
							string.IsNullOrEmpty ( asciiInfo.Comment )			// Format Item 4: Comment, if present, else nothing
								? string.Empty									//		Since there is no comment, show nothing.
								: string.Concat (								//		Comments get wrapped in parentheses and separated by a space.
									SpecialCharacters.SPACE_CHAR ,				//		Leading space 
									SpecialCharacters.PARENTHESIS_LEFT ,		//      and left parenthesis
									asciiInfo.Comment ,							//		Comment from document
									SpecialCharacters.PARENTHESIS_RIGHT )       //		Right parenthesis
						} );
				}   // foreach ( ASCIICharacterDisplayInfo asciiInfo in asciiShowMan.AllASCIICharacters )

				swAsciiTableLists.Close ( );
				swAsciiTableLists.Dispose ( );
				swAsciiTableLists = null;
			}
			catch ( Exception exAll )
			{
				Program.s_smTheApp.AppExceptionLogger.ReportException ( exAll );
			}
        }   // ASCII_Table_Gen