public TimedWaitTestCase ( ) { } // public TimedWaitTestCase (1 of 2) /// <summary> /// Use this constructor to create fully populated objects from a string /// read from a file of delimited text records. /// </summary> /// <param name="pstrRecord"> /// Pass in the record. /// </param> /// <param name="pchrDelimiter"> /// Identify the delimiter, so that I can change my mind about my choice /// of field delimiter. /// </param> public TimedWaitTestCase ( string pstrRecord ) { string [ ] astrFields = pstrRecord.Split ( s_achrFieldDelimiter ); if ( astrFields.Length == s_astrTimedWaitTestCaseInfo.Length ) { // Input contains the expected number of fields. int intPosition = ArrayInfo.ARRAY_INVALID_INDEX; foreach ( string strField in astrFields ) { intPosition++; if ( intPosition == s_intPos_puintWaitSeconds ) { uint.TryParse ( strField , out _twtc_puintWaitSeconds ); } else if ( intPosition == s_intPos_pstrCountdownWaitingFor ) { _twtc_pstrCountdownWaitingFor = strField; } else if ( intPosition == s_intPos_pclrTextColor ) { _twtc_pclrTextColor = ( ConsoleColor ) System.Enum.Parse ( _twtc_pclrTextColor.GetType ( ) , strField ); } else if ( intPosition == s_intPos_pclrTextBackgroundColor ) { _twtc_pclrTextBackgroundColor = ( ConsoleColor ) System.Enum.Parse ( _twtc_pclrTextBackgroundColor.GetType ( ) , strField ); } else if ( intPosition == s_intPos_penmInterruptCriterion ) { _twtc_penmInterruptCriterion = ( DisplayAids.InterruptCriterion ) System.Enum.Parse ( _twtc_penmInterruptCriterion.GetType ( ) , strField ); } } // foreach ( string strField in astrFields ) } // TRUE (expected outcome) block, if ( astrFields.Length == s_astrTimedWaitTestCaseInfo.Length ) else { // The input didn't split into the expected number of fields. string strMsg = string.Format ( Properties.Resources.TIMED_WAIT_TEST_CTOR_ERROR_3 , new object [ ] { pstrRecord , s_astrTimedWaitTestCaseInfo.Length , astrFields.Length , Environment.NewLine } ); throw new ArgumentException ( strMsg , Properties.Resources.TIMED_WAIT_TEST_CTOR_ARGNAME ); } // FALSE (exception) block, if ( astrFields.Length == s_astrTimedWaitTestCaseInfo.Length ) } // public TimedWaitTestCase (2 of 2)
} // public void NormalExit (7 of 8) /// <summary> /// Exit the program normally, optionally returning a nonzero status /// code, and optionally calling WaitForCarbonUnit to suspend execution /// until the operator has a chance to read the output or capture it /// into the clipboard. /// </summary> /// <param name="puintStatusCode"> /// This unsigned integer specifies the program's exit code. /// </param> /// <param name="pstrOperatorPrompt"> /// This string specifies an alternative message for method /// WaitForCarbonUnit to display. If this is an empty string or null /// reference, a default message, "Please press the ENTER (Return) key /// to exit the program." is shown. /// </param> /// <param name="penmNormalExitAction"> /// This member of the NormalExitAction enumeration controls whether to /// use WaitForCarbonUnit to suspend execution until an operator has a /// chance to read the output. See the NormalExitAction enumeration for /// details. /// </param> /// <param name="puintSecondsToWait"> /// Specify the number of seconds to wait, which must be a whole number /// greater than or equal to zero. Setting this value to zero causes the /// method to wait for 30 seconds. /// </param> /// <param name="pstrCountdownWaitingFor"> /// Specify the text to display along with the remaining time. If this /// argument is null (Nothing in Visual Basic) or the empy string, the /// method uses a default message. /// /// Currently, the default description is "Program ending," which is /// taken from a resource string in the WizardWrx.ConsoleAids class that /// implements this feature. /// </param> /// <param name="pclrTextColor"> /// Specify a member of the ConsoleColor enumeration to control the text /// color used to display the countdown message. /// /// To use the default (current) screen colors, specify the same /// ConsoleColor value for pclrTextColor and pclrTextBackgroundColor. /// </param> /// <param name="pclrTextBackgroundColor"> /// Specify a member of the ConsoleColor enumeration to control the /// background color used to display the countdown message. /// /// To use the default (current) screen colors, specify the same /// ConsoleColor value for pclrTextColor and pclrTextBackgroundColor. /// </param> /// <param name="penmInterruptCriterion"> /// Specify a member of the DisplayAids.InterruptCriterion enumeration /// to indicate whether you want the timed wait to be interruptible, and /// under what conditions. /// </param> /// <remarks> /// This method differs sufficiently from overload 2 that it stands on /// its own. Theoretically, every other overload could call this one. /// </remarks> public void NormalExit ( uint puintStatusCode , string pstrOperatorPrompt , NormalExitAction penmNormalExitAction , uint puintSecondsToWait , string pstrCountdownWaitingFor , ConsoleColor pclrTextColor , ConsoleColor pclrTextBackgroundColor , DisplayAids.InterruptCriterion penmInterruptCriterion ) { if ( penmNormalExitAction != NormalExitAction.Silent ) { this.DisplayEOJMessage ( ); } // if ( penmNormalExitAction != NormalExitAction.Silent ) switch ( penmNormalExitAction ) { case NormalExitAction.ExitImmediately: case NormalExitAction.Silent: Environment.Exit ( ( int ) puintStatusCode ); break; case NormalExitAction.Timed: Console.WriteLine ( pstrOperatorPrompt ); DisplayAids.TimedWait ( puintSecondsToWait , // puintWaitSeconds pstrCountdownWaitingFor , // pstrCountdownWaitingFor ConsoleColor.Black , // pclrTextColor ConsoleColor.Black , // pclrTextBackgroundColor penmInterruptCriterion ); // penmInterruptCriterion Environment.Exit ( ( int ) puintStatusCode ); break; case NormalExitAction.HaltOnError: if ( puintStatusCode == MagicNumbers.ERROR_SUCCESS ) { // No news is good news. Keep going. Environment.Exit ( MagicNumbers.ERROR_SUCCESS ); } // TRUE block, if ( puintStatusCode == MagicNumbers.ERROR_SUCCESS ) else { // There was an error. Halt the script. DisplayAids.WaitForCarbonUnit ( pstrOperatorPrompt ); Environment.Exit ( ( int ) puintStatusCode ); } // FALSE block, if ( puintStatusCode == MagicNumbers.ERROR_SUCCESS ) break; case NormalExitAction.WaitForOperator: DisplayAids.WaitForCarbonUnit ( pstrOperatorPrompt ); Environment.Exit ( ( int ) puintStatusCode ); break; default: Console.WriteLine ( Properties.Resources.NORMAL_EXIT_INTERNAL_ERROR , // Message template penmNormalExitAction , // Token 0 NormalExitAction.WaitForOperator , // Token 1 Environment.NewLine ); // Token 2 DisplayAids.WaitForCarbonUnit ( pstrOperatorPrompt ); Environment.Exit ( ( int ) puintStatusCode ); break; } // switch ( penmNormalExitAction ) } // public void NormalExit (8 of 8)