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