示例#1
0
        private void HandleParseError(Exception error, ref int pos)
        {
            if (error == null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            switch (_defaultParseErrorAction)
            {
            case ParseErrorAction.ThrowException:
                throw error;

            case ParseErrorAction.RaiseEvent:
                var e = new ParseErrorEventArgs(error, ParseErrorAction.ThrowException);
                OnParseError(e);

                switch (e.Action)
                {
                case ParseErrorAction.ThrowException:
                    throw e.Error;

                case ParseErrorAction.RaiseEvent:
                    throw new InvalidOperationException(Resources.ParseErrorActionInvalid);

                case ParseErrorAction.AdvanceToNextLine:
                    if (pos >= 0)
                    {
                        ReadNextRecord(false, true);
                    }
                    break;

                default:
                    throw new NotSupportedException(Resources.ParseErrorActionNotSupport);
                }
                break;

            case ParseErrorAction.AdvanceToNextLine:
                if (pos >= 0)
                {
                    ReadNextRecord(false, true);
                }
                break;

            default:
                throw new NotSupportedException(Resources.ParseErrorActionNotSupport);
            }
        }
示例#2
0
        protected virtual void OnParseError(ParseErrorEventArgs e)
        {
            var handler = ParseError;

            handler?.Invoke(this, e);
        }