private static void LogMissingFieldFound(string[] headerNames, int index, IReadingContext context) { if (headerNames != null && headerNames.Length != 0) { var message = $"Field with names ['{string.Join("', '", headerNames)}'] at index '{index}' does not exist."; _logger.Warn(message); } else { var msg = $"Field at index '{index}' does not exist"; _logger.Warn(msg); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <param name="disposing">True if the instance needs to be disposed of.</param> protected virtual void Dispose(bool disposing) { if (disposed) { return; } if (disposing) { context?.Dispose(); } context = null; disposed = true; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <param name="disposing">True if the instance needs to be disposed of.</param> protected virtual void Dispose(bool disposing) { if (disposed) { return; } if (disposing) { fieldReader?.Dispose(); } fieldReader = null; context = null; disposed = true; }
/// <summary> /// Initializes a new instance of the <see cref="ValidationException"/> class. /// </summary> /// <param name="context">The reading context.</param> public ValidationException(IReadingContext context) : base(context) { }
/// <summary> /// Initializes a new instance of the <see cref="TypeConverterException"/> class /// with a specified error message. /// </summary> /// <param name="typeConverter">The type converter.</param> /// <param name="memberMapData">The member map data.</param> /// <param name="text">The text.</param> /// <param name="context">The reading context.</param> /// <param name="message">The message that describes the error.</param> public TypeConverterException(ITypeConverter typeConverter, MemberMapData memberMapData, string text, IReadingContext context, string message) : base(context, message) { TypeConverter = typeConverter; MemberMapData = memberMapData; Text = text; }
/// <summary> /// Creates a new parser using the given <see cref="FieldReader"/>. /// </summary> /// <param name="fieldReader">The field reader.</param> public CsvParser(IFieldReader fieldReader) { this.fieldReader = fieldReader ?? throw new ArgumentNullException(nameof(fieldReader)); context = fieldReader.Context as IReadingContext ?? throw new InvalidOperationException($"For {nameof( FieldReader )} to be used in {nameof( CsvParser )}, {nameof( FieldReader.Context )} must also implement {nameof( IReadingContext )}."); }
/// <summary> /// Initializes a new instance of the <see cref="CsvHelperException"/> class /// with a specified error message and a reference to the inner exception that /// is the cause of this exception. /// </summary> /// <param name="context">The reading context.</param> /// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> public CsvHelperException(IReadingContext context, string message, Exception innerException) : base(message, innerException) { ReadingContext = context; }
/// <summary> /// Initializes a new instance of the <see cref="ReaderException"/> class /// with a specified error message. /// </summary> /// <param name="context">The reading context.</param> /// <param name="message">The message that describes the error.</param> public ReaderException(IReadingContext context, string message) : base(context, message) { }
/// <summary> /// Creates a new <see cref="CsvFieldReader"/> using the given /// <see cref="TextReader"/>, <see cref="Configuration.Configuration"/> /// and leaveOpen flag. /// </summary> /// <param name="reader">The text reader.</param> /// <param name="configuration">The configuration.</param> /// <param name="leaveOpen">A value indicating if the <see cref="TextReader"/> should be left open when disposing.</param> public CsvFieldReader(TextReader reader, Configuration.Configuration configuration, bool leaveOpen) { context = new ReadingContext(reader, configuration, leaveOpen); }
/// <summary> /// Initializes a new instance of the <see cref="BadDataException"/> class. /// </summary> /// <param name="context">The reading context.</param> public BadDataException(IReadingContext context) : base(context) { }
/// <summary> /// Initializes a new instance of the <see cref="MissingFieldException"/> class /// with a specified error message. /// </summary> /// <param name="context">The reading context.</param> /// <param name="message">The message that describes the error.</param> public MissingFieldException(IReadingContext context, string message) : base(context, message) { }
/// <summary> /// Initializes a new instance of the <see cref="MissingFieldException"/> class /// with a specified error message and a reference to the inner exception that /// is the cause of this exception. /// </summary> /// <param name="context">The reading context.</param> /// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> public MissingFieldException(IReadingContext context, string message, Exception innerException) : base(context, message, innerException) { }
/// <summary> /// Initializes a new instance of the <see cref="MissingFieldException"/> class. /// </summary> /// <param name="context">The reading context.</param> public MissingFieldException(IReadingContext context) : base(context) { }
/// <summary> /// Initializes a new instance of the <see cref="BadDataException"/> class /// with a specified error message and a reference to the inner exception that /// is the cause of this exception. /// </summary> /// <param name="context">The reading context.</param> /// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> public BadDataException(IReadingContext context, string message, Exception innerException) : base(context, message, innerException) { }
/// <summary> /// Initializes a new instance of the <see cref="BadDataException"/> class /// with a specified error message. /// </summary> /// <param name="context">The reading context.</param> /// <param name="message">The message that describes the error.</param> public BadDataException(IReadingContext context, string message) : base(context, message) { }
/// <summary> /// Initializes a new instance of the <see cref="ValidationException"/> class /// with a specified error message. /// </summary> /// <param name="context">The reading context.</param> /// <param name="message">The message that describes the error.</param> public ValidationException(IReadingContext context, string message) : base(context, message) { }
/// <summary> /// Initializes a new instance of the <see cref="TypeConverterException"/> class. /// </summary> /// <param name="context">The reading context.</param> public TypeConverterException(IReadingContext context) : base(context) { }
/// <summary> /// Initializes a new instance of the <see cref="ValidationException"/> class /// with a specified error message and a reference to the inner exception that /// is the cause of this exception. /// </summary> /// <param name="context">The reading context.</param> /// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> public ValidationException(IReadingContext context, string message, Exception innerException) : base(context, message, innerException) { }
private void badData(IReadingContext attr) { System.Diagnostics.Debug.WriteLine(attr.RawRecord); }
private static void LogHeaderValidatationFailed(bool isValid, string[] headerNames, int headerNameIndex, IReadingContext context) { if (!isValid) { string message = string.Format("Header matching ['{0}'] names at index {1} was not found. ", string.Join("', '", headerNames), headerNameIndex); _logger.Warn(message); } }
/// <summary> /// Initializes a new instance of the <see cref="ReaderException"/> class. /// </summary> /// <param name="context">The reading context.</param> public ReaderException(IReadingContext context) : base(context) { }
/// <summary> /// Initializes a new instance of the <see cref="TypeConverterException"/> class /// with a specified error message and a reference to the inner exception that /// is the cause of this exception. /// </summary> /// <param name="context">The reading context.</param> /// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param> public TypeConverterException(IReadingContext context, string message, Exception innerException) : base(context, message, innerException) { }
/// <summary> /// Initializes a new instance of the <see cref="CsvHelperException"/> class. /// </summary> public CsvHelperException(IReadingContext context) { ReadingContext = context; }