Die neueste CSVHelper -Konfiguration hat mehrere Mitglieder in Readonly geändert und Zusammenstellungsfehler für vorhandC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Die neueste CSVHelper -Konfiguration hat mehrere Mitglieder in Readonly geändert und Zusammenstellungsfehler für vorhand

Post by Anonymous »

Der folgende C# -Code, der mit CSVReader verwendet wird, wobei der Variablenleser ein StreamReader :
ist

Code: Select all

DataTable dataTable = null;
this._csvHeaders = null;

using (reader)
{
using (CsvReader csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
csv.Configuration.HasHeaderRecord = true;
csv.Configuration.MissingFieldFound = (field, index, context) => AddMissingFieldParseError(field, context.Row, index);
csv.Configuration.BadDataFound = (context) => AddBadDataFoundParseError(context.Field, context.Row);

using (CsvDataReader dataReader = new CsvDataReader(csv))
{
// Validate headers
this._csvHeaders = csv.Context.Reader.HeaderRecord.ToList();
TrimHeaderNames(ref _csvHeaders);

string errorMessage = string.Empty;

if (!ValidateHeaders(_csvHeaders, out errorMessage))
{
XOperationError operationError = new XOperationError("Duplicated error found", errorMessage);
this.ParseErrors.Clear();
this.ParseErrors.Add(0, new List { operationError });
return null;
}

dataTable = new DataTable();
dataTable.Load(dataReader);
}
}
}
Jetzt funktioniert es nicht mehr wie HaSheaDeerRecord , fehlteFoundFound , baddatafound alle schreibgeschützt.

Code: Select all

CsvConfiguration config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
HasHeaderRecord = true,
MissingFieldFound = (field, index, context) => AddMissingFieldParseError(field, context.Row, index),
BadDataFound = (context) => AddBadDataFoundParseError(context.Field, context.Row)
};
< /code>
Jetzt beschwert es: < /p>
[list]
[*]MissingFieldFound
nimmt keine 3 Argumente an
[*]

Code: Select all

BadDataFoundArgs
enthält keine Definition für Zeile
[/list]
Ich bin wirklich verwirrt. Sind diese nur Syntaxfehler?
Eine Hilfe wird geschätzt.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post