Beispiel #1
0
        }               // public string DisplayBitMaskFromMultilineString (2 OF 2)

        #endregion      // Public Instance Methods


        #region Private Instance Methods
        private void InitializeInstance(
            int pintTypeInfoIndex,
            object pbytBitMask,
            BitArray32.BitDisplayOrder penmBitDisplayOrder)
        {
            _bclTypeInfo = BitHelpers.s_abclintegertypeinfo [pintTypeInfoIndex];

            _objUnderlyingInteger = pbytBitMask;
            _enmBitDisplayOrder   = penmBitDisplayOrder;

            _strDecimalRepresentation = string.Format(
                FORMAT_FIRST_ITEM_AS_DECIMAL,
                _objUnderlyingInteger);
            _strHexadecimalRepresentation = BitArray32.FormatIntegerAsHex(_objUnderlyingInteger);

            _strTens = BitArray32.GetRulerTens(
                (BitArray32.BitCount)_bclTypeInfo.CapacityInBits,
                _enmBitDisplayOrder);
            _strUnits = BitArray32.GetRulerUnits(
                (BitArray32.BitCount)_bclTypeInfo.CapacityInBits,
                _enmBitDisplayOrder);
            _strArrayOfBits = string.Format(
                new WizardWrx.BitMaskFormat( ),
                _enmBitDisplayOrder == BitArray32.BitDisplayOrder.LowBitToHighBit
                                        ? FORMAT_FIRST_ITEM_AS_REVERSED_BIT_ARRAY :
                FORMAT_FIRST_ITEM_AS_BIT_ARRAY,
                _objUnderlyingInteger);
        }               // private void InitializeInstance
        }   // private static void RealWorldTests


		private static void TestBitArrayRulers ( ref int pintTestNbr )
		{
			Console.WriteLine (
				"Test {0}, TestBitArrayRulers Begin:" ,
				++pintTestNbr );

			int intSampleIndex = Util.ARRAY_FIRST_ELEMENT;

			foreach ( BitArray32.BitCount enmBitCount in s_aenmBitCount )
			{
				Console.WriteLine (
					"{2}    Bit Count = {0} (integer value = {1}):" ,
					enmBitCount ,
					( int ) enmBitCount ,
					Environment.NewLine );

				foreach ( BitArray32.BitDisplayOrder enmBitDisplayOrder in s_aenmBitDisplayOrder )
				{
					Console.WriteLine (
						"{2}        Bit Order = {0} (integer value = {1}):{2}" ,
						enmBitDisplayOrder ,
						( int ) enmBitDisplayOrder ,
					Environment.NewLine );

					try
					{
						Console.WriteLine (
							"        {0}{6}        {1}{6}        {2} ({3} value as integer: hexadecimal = {4} = {5:N0}  decimal){6}" ,		// Format control string
							new object [ ]
							{
								BitArray32.GetRulerTens (
									enmBitCount ,
									enmBitDisplayOrder ) ,																					// Format Item 0 = Tens row of ruler
								BitArray32.GetRulerUnits (
									enmBitCount ,
									enmBitDisplayOrder ) ,																					// Format Item 1 = Units row of ruler
								string.Format (
									new WizardWrx.BitMaskFormat ( ) ,
									enmBitDisplayOrder == BitArray32.BitDisplayOrder.LowBitToHighBit
										? FORMAT_FIRST_ITEM_AS_REVERSED_BIT_ARRAY
										: FORMAT_FIRST_ITEM_AS_BIT_ARRAY ,
									s_aobjRulerSample [ intSampleIndex ] ) ,																// Format Item 2 = Bit mask of Sample
								BitHelpers.InfoForIntegralType ( s_aobjRulerSample [ intSampleIndex ].GetType ( ) ) ,						// Format Item 3 = BCLIntegerTypeInfo type information (ToString reports all of its properties.)
								BitArray32.FormatIntegerAsHex ( s_aobjRulerSample [ intSampleIndex ] ) ,									// Format Item 4 = Formatted Hexadecimal representation of Sample.
								s_aobjRulerSample [ intSampleIndex ] ,																		// Format Item 5 = Formatted Decimal representation of Sample.
								Environment.NewLine																							// Format Item 6 = Embedded Newline
							} );
					}
					catch ( Exception exAllKinds )
					{
						Console.WriteLine (
							"An {0} exception occurred:{4}{4}    Message:        {1}{4}    Method:         {2}{4}    Stack Trace: {3}{4}" ,
							new object [ ]
							{
								exAllKinds.GetType ( ).FullName ,				// Format Item 0 = Exception Type
								Util.BeautifyExceptionMessage (
									exAllKinds.Message , 4 ) ,					// Format Item 1 = Exception Message
								exAllKinds.TargetSite ,							// Format Item 2 = Exception Method
								Util.BeautifyStackTrace (
									exAllKinds.StackTrace , 17 ) ,				// Format Item 3 = Exception Stack Trace
								Environment.NewLine								// Format Item 4 = Embedded Newline
							} );

						if ( exAllKinds.InnerException == null )
						{
							Console.WriteLine (
								"There are further details.{0}" ,
								Environment.NewLine );
						}	// TRUE (There is at least one inner exception.) block, if ( exAllKinds.InnerException == null )
						else
						{
							ReportInnerException ( exAllKinds.InnerException );
						}	// FALSE (There are no nested exceptions.) block, if ( exAllKinds.InnerException == null )
					}	// catch ( Exception exAllKinds ) Try/Catch block
				}	// foreach ( BitArray32.BitDisplayOrder enmRulelerDirection in s_aenmBitDisplayOrder )

				intSampleIndex++;		// Increment the subscript AFTER we use it!
			}	// foreach ( BitArray32.BitCount enmBitCount in s_aenmBitCount )

			Console.WriteLine (
				"Test {0} Done{1}" ,	// Format control string
				pintTestNbr ,			// Format Item 0 = Test Number
				Environment.NewLine );	// Format Item 1 = Embedded newline
		}	// private static void TestBitArrayRulers