/// <summary> /// Reads a record from the CSV file. /// </summary> /// <returns>A <see cref="List{String}" /> of fields for the record read. /// If there are no more records, null is returned.</returns> public virtual string[] Read() { CheckDisposed(); try { var row = ReadLine(); if (configuration.DetectColumnCountChanges && row != null) { if (columnCount > 0 && (columnCount != row.Length || #if NET_2_0 EnumerableHelper.Any(row, field => field == null) #else row.Any(field => field == null) #endif )) { throw new CsvBadDataException("An inconsistent number of columns has been detected."); } columnCount = row.Length; } return(row); } catch (Exception ex) { ExceptionHelper.AddExceptionDataMessage(ex, this, null, null, null, null); throw; } }
/// <summary> /// Reads a record from the CSV file. /// </summary> /// <returns>A <see cref="List{String}" /> of fields for the record read. /// If there are no more records, null is returned.</returns> public virtual string[] Read() { CheckDisposed(); try { var row = ReadLine(); if (configuration.DetectColumnCountChanges && row != null) { if (columnCount > 0 && (columnCount != row.Length || #if NET_2_0 EnumerableHelper.Any(row, field => field == null) #else row.Any(field => field == null) #endif )) { throw ExceptionHelper.GetReaderException <CsvBadDataException>("An inconsistent number of columns has been detected.", null, this, null, null, null, null); } columnCount = row.Length; } return(row); } catch (CsvHelperException) { // We threw it, so let it go. throw; } catch (Exception ex) { throw ExceptionHelper.GetReaderException <CsvParserException>("A parsing error occurred.", ex, this, null, null, null, null); } }
/// <summary> /// Reads a record from the CSV file. /// </summary> /// <returns>A <see cref="List{String}" /> of fields for the record read. /// If there are no more records, null is returned.</returns> public virtual string[] Read() { CheckDisposed(); try { var row = ReadLine(); if (configuration.DetectColumnCountChanges) { if (columnCount > 0 && (columnCount != row.Length || #if NET_2_0 EnumerableHelper.Any(row, field => field == null) #else row.Any(field => field == null) #endif )) { throw new CsvBadDataException("An inconsistent number of columns has been detected."); } columnCount = row.Length; } return(row); } catch (CsvHelperException) { // We threw it, so let it go. throw; } catch (Exception ex) { throw new CsvParserException(string.Format("A parsing error occurred. Line: {0} Character: {1}", currentRow, currentCharacter), ex); } }
private void EnsureRecipientValid(string recipient) { if (recipient.Length != 13 || !recipient.StartsWith("+") || EnumerableHelper.Any(EnumerableHelper.FindAll(recipient.Substring(1), c => !char.IsNumber(c)))) { throw new ArgumentException("Recipient must be in international +420123456789 format.", "recipient"); } }
bool IComponentKindManager <int, ComponentKindSet> .Overlaps(ComponentKindSet componentKindSet, IEnumerable <ComponentKind> componentKinds) { if (componentKindSet == null) { throw new ArgumentNullException(nameof(componentKindSet)); } if (componentKinds == null) { throw new ArgumentNullException(nameof(componentKinds)); } return(EnumerableHelper.Any(componentKinds, index => componentKindSet[index])); }