#region " © Copyright 2005-07 to Marcos Meli - http://www.marcosmeli.com.ar" // Errors, suggestions, contributions, send a mail to: marcos@filehelpers.com. #endregion using System; using System.Diagnostics; namespace FileHelpers { /// Contains error information of the class. [DelimitedRecord("|")] [IgnoreFirst(2)] #if NET_2_0 [DebuggerDisplay("Line: {LineNumber}. Error: {ExceptionInfo.Message}.")] #endif public sealed class ErrorInfo { internal ErrorInfo() { } #if NET_2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] #endif internal int mLineNumber; /// The line number of the error public int LineNumber { get { return mLineNumber; } } #if NET_2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] #endif [FieldQuoted(QuoteMode.OptionalForBoth)] internal string mRecordString = string.Empty; /// The string of the record of the error. public string RecordString { get { return mRecordString; } } #if NET_2_0 [DebuggerBrowsable(DebuggerBrowsableState.Never)] #endif [FieldConverter(typeof(ExceptionConverter))] [FieldQuoted(QuoteMode.OptionalForBoth)] internal Exception mExceptionInfo; /// The exception that indicates the error. public Exception ExceptionInfo { get { return mExceptionInfo; } } internal class ExceptionConverter : ConverterBase { public override string FieldToString(object from) { if (from == null) return String.Empty; else { if (from is ConvertException) return "In the field '" + ((ConvertException) from).FieldName + "': " + ((ConvertException) from).Message.Replace(StringHelper.NewLine, " -> "); else return ((Exception) from).Message.Replace(StringHelper.NewLine, " -> "); } } public override object StringToField(string from) { return new Exception(from); } } } }