public CsvReader(TextReader reader, bool hasHeaders, char delimiter, char quote, char escape, char comment, bool trimSpaces, int bufferSize) { #if DEBUG && !WINDOWS_8 && !UWP var stackTrace = new StackTrace(); _allocStack = stackTrace; #endif if (reader == null) { throw new ArgumentNullException(nameof(reader)); } if (bufferSize <= 0) { throw new Exception(Resources.BufferSizeSmall); } _bufferSize = bufferSize; if (reader is StreamReader streamReader) { var stream = streamReader.BaseStream; if (stream.CanSeek) { // 处理返回小于或等于0的错误实现 if (stream.Length > 0) { _bufferSize = (int)Math.Min(bufferSize, stream.Length); } } } _reader = reader; _delimiter = delimiter; _quote = quote; _escape = escape; _comment = comment; _hasHeaders = hasHeaders; _trimSpaces = trimSpaces; _supportsMultiline = true; _skipEmptyLines = true; _currentRecordIndex = -1; _defaultParseErrorAction = ParseErrorAction.RaiseEvent; }
/// <summary> /// Initializes a new instance of the ParseErrorEventArgs class. /// </summary> /// <param name="error">The error that occured.</param> /// <param name="defaultAction">The default action to take.</param> public ParseErrorEventArgs(MalformedCsvException error, ParseErrorAction defaultAction) : base() { _error = error; _action = defaultAction; }
/// <summary> /// Initializes a new instance of the ParseErrorEventArgs class. /// </summary> /// <param name="error"> The error that occured. </param> /// <param name="defaultAction"> The default action to take. </param> public ParseErrorEventArgs(MalformedCsvException error, ParseErrorAction defaultAction) : base() { this.error = error; this.action = defaultAction; }
/// <summary> /// Initializes a new instance of the ParseErrorEventArgs class. /// </summary> /// <param name="error">The error that occurred.</param> /// <param name="action">The action to take.</param> public ParseErrorEventArgs(MalformedRecordException error, ParseErrorAction action) : base() { this.Error = error; this.Action = action; }
/// <summary> /// Initializes a new instance of the ParseErrorEventArgs class. /// </summary> /// <param name="error">The error that occured.</param> /// <param name="defaultAction">The default action to take.</param> public ParseErrorEventArgs(MalformedCsvException error, ParseErrorAction defaultAction) { Error = error; Action = defaultAction; }
/// <summary> /// Initializes a new instance of the ParseErrorEventArgs class. /// </summary> /// <param name="error">The error that occured.</param> /// <param name="defaultAction">The default action to take.</param> public ParseErrorEventArgs(Exception error, ParseErrorAction defaultAction) : base() { _error = error; _action = defaultAction; }
/// <summary> /// Initializes a new instance of the ParseErrorEventArgs class. /// </summary> /// <param name="error">The error that occured.</param> /// <param name="defaultAction">The default action to take.</param> public ParseErrorEventArgs(MalformedCsvException error, ParseErrorAction defaultAction) { _error = error; Action = defaultAction; }
/// <summary> /// Initializes a new instance of the ParseErrorEventArgs class. /// </summary> /// <param name="error"> /// The error that occured. /// </param> /// <param name="defaultAction"> /// The default action to take. /// </param> public ParseErrorEventArgs(CsvException error, ParseErrorAction defaultAction) { this._error = error; this._action = defaultAction; }