private void ValidateCurrentFormattingState(FormattingState expectedFormattingState, object obj) { if (this.currentFormattingState != expectedFormattingState) { string str = "format-*"; StartData data = obj as StartData; if (data != null) { if (data.shapeInfo.GetType() == typeof(WideViewHeaderInfo)) { str = "format-wide"; } else if (data.shapeInfo.GetType() == typeof(TableHeaderInfo)) { str = "format-table"; } else if (data.shapeInfo.GetType() == typeof(ListViewHeaderInfo)) { str = "format-list"; } else if (data.shapeInfo.GetType() == typeof(ComplexViewHeaderInfo)) { str = "format-complex"; } } string message = StringUtil.Format(FormatAndOut_out_xxx.OutLineOutput_OutOfSequencePacket, obj.GetType().FullName, str); ErrorRecord errorRecord = new ErrorRecord(new InvalidOperationException(), "ConsoleLineOutputOutOfSequencePacket", ErrorCategory.InvalidData, null) { ErrorDetails = new ErrorDetails(message) }; base.TerminatingErrorContext.ThrowTerminatingError(errorRecord); } }
private void ValidateCurrentFormattingState(FormattingState expectedFormattingState, object obj) { // check if we are in the expected formatting state if (_currentFormattingState != expectedFormattingState) { // we are not in the expected state, some message is out of sequence, // need to abort the command string violatingCommand = "format-*"; StartData sdObj = obj as StartData; if (sdObj != null) { if (sdObj.shapeInfo is WideViewHeaderInfo) { violatingCommand = "format-wide"; } else if (sdObj.shapeInfo is TableHeaderInfo) { violatingCommand = "format-table"; } else if (sdObj.shapeInfo is ListViewHeaderInfo) { violatingCommand = "format-list"; } else if (sdObj.shapeInfo is ComplexViewHeaderInfo) { violatingCommand = "format-complex"; } } string msg = StringUtil.Format(FormatAndOut_out_xxx.OutLineOutput_OutOfSequencePacket, obj.GetType().FullName, violatingCommand); ErrorRecord errorRecord = new ErrorRecord( new InvalidOperationException(), "ConsoleLineOutputOutOfSequencePacket", ErrorCategory.InvalidData, null); errorRecord.ErrorDetails = new ErrorDetails(msg); this.TerminatingErrorContext.ThrowTerminatingError(errorRecord); } }