using System; using System.Diagnostics; using System.ComponentModel; namespace FileHelpers { /// /// This class allows you to set some options of the records but at runtime. /// With this options the library is more flexible than never. /// [EditorBrowsable(EditorBrowsableState.Advanced)] public abstract class RecordOptions { #if NET_2_0 [DebuggerDisplay("FileHelperEngine for type: {RecordType.Name}. ErrorMode: {ErrorManager.ErrorMode.ToString()}. Encoding: {Encoding.EncodingName}")] #endif internal RecordInfo mRecordInfo; internal RecordOptions(RecordInfo info) { mRecordInfo = info; mRecordConditionInfo = new RecordConditionInfo(info); mIgnoreCommentInfo = new IgnoreCommentInfo(info); } /// Indicates the number of first lines to be discarded. public int IgnoreFirstLines { get { return mRecordInfo.mIgnoreFirst; } set { ExHelper.PositiveValue(value); mRecordInfo.mIgnoreFirst= value; } } /// Indicates the number of lines at the end of file to be discarded. public int IgnoreLastLines { get { return mRecordInfo.mIgnoreLast; } set { ExHelper.PositiveValue(value); mRecordInfo.mIgnoreLast = value; } } /// Indicates that the engine must ignore the empty lines while reading. public bool IgnoreEmptyLines { get { return mRecordInfo.mIgnoreEmptyLines; } set { mRecordInfo.mIgnoreEmptyLines= value; } } private RecordConditionInfo mRecordConditionInfo; /// Allow to tell the engine what records must be included or excluded while reading. public RecordConditionInfo RecordCondition { get { return mRecordConditionInfo; } } private IgnoreCommentInfo mIgnoreCommentInfo; /// Indicates that the engine must ignore the lines with this comment marker. public IgnoreCommentInfo IgnoreCommentedLines { get { return mIgnoreCommentInfo; } } /// Allow to tell the engine what records must be included or excluded while reading. [EditorBrowsable(EditorBrowsableState.Advanced)] public sealed class RecordConditionInfo { RecordInfo mRecordInfo; internal RecordConditionInfo(RecordInfo ri) { mRecordInfo = ri; } /// The condition used to include or exclude records. public RecordCondition Condition { get { return mRecordInfo.mRecordCondition; } set { mRecordInfo.mRecordCondition = value; } } /// The selector used by the . public string Selector { get { return mRecordInfo.mRecordConditionSelector; } set { mRecordInfo.mRecordConditionSelector = value; } } } /// Indicates that the engine must ignore the lines with this comment marker. [EditorBrowsable(EditorBrowsableState.Advanced)] public sealed class IgnoreCommentInfo { RecordInfo mRecordInfo; internal IgnoreCommentInfo(RecordInfo ri) { mRecordInfo = ri; } /// /// Indicates that the engine must ignore the lines with this comment marker. /// An emty string or null indicates that the engine dont look for comments /// public string CommentMarker { get { return mRecordInfo.mCommentMarker; } set { if (value != null) value = value.Trim(); mRecordInfo.mCommentMarker = value; } } /// Indicates if the comment can have spaces or tabs at left (true by default) public bool InAnyPlace { get { return mRecordInfo.mCommentAnyPlace; } set { mRecordInfo.mCommentAnyPlace = value; } } } } }