Exemplo n.º 1
0
 public void AssCsvColumnInfo(CsvColumnInfo info)
 {
     if (info == null)
         throw new ArgumentNullException("info");
     _csvMetadata.Add(info);
 }
Exemplo n.º 2
0
        private ValidationFailReason ValidateColumnValue(CsvColumnInfo info)
        {
            object value = null;
            try
            {
                checked
                {
                    value = ((IDataRecord)_reader)[info.Name];
                }
            }
            catch (Exception)
            {
                return ValidationFailReason.TypeConvertionFailure;
            }

            if (Convert.IsDBNull(value) && !info.IsNullable &&
                (_mode != ImportMode.BulkDelete || info.DeletionKey))
                return ValidationFailReason.NullabilityViolation;

            if (value is string)
            {
                if (info.MaxLength != -1 && ((string)value).Length > info.MaxLength)
                    return ValidationFailReason.MaxLengthViolation;
            }

            return ValidationFailReason.None;
        }