Ejemplo n.º 1
0
        private ReadWithCommentResultType HandleUncommonAdvanceResults(ReaderStateMachine.AdvanceResult res, char?lastRead)
        {
            string c;

            if (lastRead.HasValue)
            {
                c = lastRead.Value.ToString();
            }
            else
            {
                c = "<end of data>";
            }

            return
                (res switch
            {
                ReaderStateMachine.AdvanceResult.Exception_ExpectedEndOfRecord => Throw.InvalidOperationException_Returns <ReadWithCommentResultType>($"Encountered '{c}' when expecting end of record"),
                ReaderStateMachine.AdvanceResult.Exception_InvalidState => Throw.InvalidOperationException_Returns <ReadWithCommentResultType>($"Internal state machine is in an invalid state due to a previous error"),
                ReaderStateMachine.AdvanceResult.Exception_StartEscapeInValue => Throw.InvalidOperationException_Returns <ReadWithCommentResultType>($"Encountered '{c}', starting an escaped value, when already in a value"),
                ReaderStateMachine.AdvanceResult.Exception_UnexpectedCharacterInEscapeSequence => Throw.InvalidOperationException_Returns <ReadWithCommentResultType>($"Encountered '{c}' in an escape sequence, which is invalid"),
                ReaderStateMachine.AdvanceResult.Exception_ExpectedEndOfRecordOrValue => Throw.InvalidOperationException_Returns <ReadWithCommentResultType>($"Encountered '{c}' when expecting the end of a record or value"),
                ReaderStateMachine.AdvanceResult.Exception_UnexpectedEnd => Throw.InvalidOperationException_Returns <ReadWithCommentResultType>($"Data ended unexpectedly"),
                // this is CRAZY unlikely, but indicates that the TransitionMatrix used was incorrect
                ReaderStateMachine.AdvanceResult.Exception_UnexpectedLineEnding => Throw.ImpossibleException_Returns <ReadWithCommentResultType, T>($"Unexpected {nameof(Cesil.ReadRowEnding)} value encountered", Configuration),
                // likewise, CRAZY unlikely
                ReaderStateMachine.AdvanceResult.Exception_UnexpectedState => Throw.ImpossibleException_Returns <ReadWithCommentResultType, T>($"Unexpected state value entered", Configuration),
                _ => Throw.ImpossibleException_Returns <ReadWithCommentResultType, T>($"Unexpected {nameof(ReaderStateMachine.AdvanceResult)}: {res}", Configuration),
            });
Ejemplo n.º 2
0
 public void ReleaseNameLookup()
 => Throw.ImpossibleException_Returns <object>("Shouldn't be possible");
Ejemplo n.º 3
0
 public NameLookup AcquireNameLookup()
 => Throw.ImpossibleException_Returns <NameLookup>("Shouldn't be possible");
Ejemplo n.º 4
0
 public void Remove(DynamicRow row)
 => Throw.ImpossibleException_Returns <object>("Shouldn't be possible");