private void LineWrittenEvent() { if (!this.disableLineWrittenEvent && (this.prompt != null)) { this.linesWritten += 1L; if (this.NeedToPrompt) { this.disableLineWrittenEvent = true; PromptHandler.PromptResponse response = this.prompt.PromptUser(this.console); this.disableLineWrittenEvent = false; switch (response) { case PromptHandler.PromptResponse.NextPage: this.linesWritten = 0L; return; case PromptHandler.PromptResponse.NextLine: this.linesWritten -= 1L; return; case PromptHandler.PromptResponse.Quit: throw new HaltCommandException(); } } } }
/// <summary> /// Called when a line was written to console. /// </summary> private void LineWrittenEvent() { // check to avoid reentrancy from the prompt handler // writing during the PromptUser() call if (_disableLineWrittenEvent) { return; } // if there is no prompting, we are done if (_prompt == null) { return; } // increment the count of lines written to the screen _linesWritten++; // check if we need to put out a prompt if (this.NeedToPrompt) { // put out the prompt _disableLineWrittenEvent = true; PromptHandler.PromptResponse response = _prompt.PromptUser(_console); _disableLineWrittenEvent = false; switch (response) { case PromptHandler.PromptResponse.NextPage: { // reset the counter, since we are starting a new page _linesWritten = 0; } break; case PromptHandler.PromptResponse.NextLine: { // roll back the counter by one, since we allow one more line _linesWritten--; } break; case PromptHandler.PromptResponse.Quit: // 1021203-2005/05/09-JonN // HaltCommandException will cause the command // to stop, but not be reported as an error. throw new HaltCommandException(); } } }