using System; using System.ComponentModel; namespace FileHelpers { /// Base class of and [EditorBrowsable(EditorBrowsableState.Never)] public abstract class ReadRecordEventArgs: EventArgs { internal ReadRecordEventArgs(string line, int lineNumber) { mRecordLine = line; mLineNumber = lineNumber; } private string mRecordLine; private int mLineNumber; /// The current line number. public int LineNumber { get { return mLineNumber; } } /// The just read record line. public string RecordLine { get { return mRecordLine; } } } /// Arguments for the #if NET_1_1 public sealed class BeforeReadRecordEventArgs: ReadRecordEventArgs #else public sealed class BeforeReadRecordEventArgs: BeforeReadRecordEventArgs { internal BeforeReadRecordEventArgs(string line) : this(line, -1) { } internal BeforeReadRecordEventArgs(string line, int lineNumber) : base(line, lineNumber) { } } /// Arguments for the public class BeforeReadRecordEventArgs : ReadRecordEventArgs #endif { internal BeforeReadRecordEventArgs(string line): this(line, -1) {} internal BeforeReadRecordEventArgs(string line, int lineNumber): base(line, lineNumber) {} private bool mSkipThisRecord = false; /// Set this property to true if you want to bypass the current line. public bool SkipThisRecord { get { return mSkipThisRecord; } set { mSkipThisRecord = value; } } } /// Arguments for the #if NET_1_1 public sealed class AfterReadRecordEventArgs: ReadRecordEventArgs { internal AfterReadRecordEventArgs(string line, object newRecord): this(line, newRecord, -1) {} internal AfterReadRecordEventArgs(string line, object newRecord, int lineNumber): base(line, lineNumber) { mRecord = newRecord; } private object mRecord; /// The current record. public object Record { get { return mRecord; } set { mRecord = value; } } #else public sealed class AfterReadRecordEventArgs: AfterReadRecordEventArgs { internal AfterReadRecordEventArgs(string line, object newRecord) : this(line, newRecord, -1) { } internal AfterReadRecordEventArgs(string line, object newRecord, int lineNumber) : base(line, newRecord, lineNumber) { } } /// Arguments for the public class AfterReadRecordEventArgs : ReadRecordEventArgs { internal AfterReadRecordEventArgs(string line, T newRecord): this(line, newRecord, -1) {} internal AfterReadRecordEventArgs(string line, T newRecord, int lineNumber): base(line, lineNumber) { mRecord = newRecord; } private T mRecord; /// The current record. public T Record { get { return mRecord; } set { mRecord = value; } } #endif private bool mSkipThisRecord = false; /// Set this property to true if you want to bypass the current record. public bool SkipThisRecord { get { return mSkipThisRecord; } set { mSkipThisRecord = value; } } } }