Detailed Method Reference
Namespace: Canley.Utility.CSV.Standard
Class: CSVRecord
Definition
public virtual bool OnImportField(string header, string value)-
Description: A virtual callback method allowing derived record classes to intercept and handle custom column imports during record initialization.
-
Workflow:
- Interception: Called during the parsing loop for each column header and value pair.
- Custom Mapping: Derived classes can override this method to parse custom properties manually, returning
trueif the field was handled orfalseto let the default system take over.
-
Parameters:
header: The name of the CSV column header currently being processed.value: The raw string value corresponding to the current column.
-
Returns:
bool-trueif the field was successfully handled by the override; otherwise,false. -
Example:
public class CustomCSVRecord : CSVRecord
{
public int customScore;
public override bool OnImportField(string header, string value)
{
if (header == "CustomScore")
{
int.TryParse(value, out customScore);
return true;
}
return base.OnImportField(header, value);
}
}TIP
Override
OnImportFieldwhen you need specialized parsing logic for non-standard columns without having to rewrite the core hydration loop.