예제 #1
0
        public static void AddExceptionData(CsvHelperException exception, int row, Type type, int?currentIndex, Dictionary <string, List <int> > namedIndexes, string[] currentRecord)
        {
            exception.Row        = row;
            exception.Type       = type;
            exception.FieldIndex = currentIndex ?? -1;

            if (namedIndexes != null)
            {
                var fieldName = (from pair in namedIndexes
                                 from index in pair.Value
                                 where index == currentIndex
                                 select pair.Key).SingleOrDefault();
                if (fieldName != null)
                {
                    exception.FieldName = fieldName;
                }
            }

            if (currentRecord != null && currentIndex > -1 && currentIndex < currentRecord.Length)
            {
                if (currentIndex.Value < currentRecord.Length)
                {
                    var fieldValue = currentRecord[currentIndex.Value];
                    exception.FieldValue = fieldValue;
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Creates a new instance of ReadingExceptionOccurredArgs.
 /// </summary>
 /// <param name="exception">The exception.</param>
 public ReadingExceptionOccurredArgs(CsvHelperException exception)
 {
     Exception = exception;
 }