/// <summary>
 /// Constructs the Csv to Object reader instance.  Most of the parameters are optional parameters
 /// with default value.  Override the default value with the custom values
 /// </summary>
 /// <param name="mapper">instance of Csv File to Domain object mapper <see cref="CsvToObjectMapper{T}"/></param>
 /// <param name="fileContent">Content of .csv/txt file</param>
 /// <param name="headerPresentInFirstRow">Does this csv/text file has header row in first line?[default=true]</param>
 /// <param name="mustMatchExpectedHeader">Should this csv file headers match with the header provided in mapper?[default=true]</param>
 /// <param name="ignoreEmptyFile">should empty file be ignored and not marked as error?[default=true]</param>
 /// <param name="ignoreColumnCountMismatch">Should ignore the additional columns if present and not report error?[default=true]</param>
 /// <param name="ignoreDataConversionError">Should ignore the rows failing because of schema/data conversion issues?[default=true]</param>
 public CsvToObjectReader(
     CsvToObjectMapper <T> mapper,
     string fileContent,
     bool headerPresentInFirstRow   = true,
     bool mustMatchExpectedHeader   = true,
     bool ignoreEmptyFile           = true,
     bool ignoreColumnCountMismatch = true,
     bool ignoreDataConversionError = true
     )
 {
     /*
      * Initialize all the initial configuration settings
      */
     this._csvContentLines = fileContent?.Split(
         new[] { Environment.NewLine },
         StringSplitOptions.None
         );
     this._mustMatchExpectedHeader = mustMatchExpectedHeader;
     this._mapper = mapper;
     this._ignoreDataConversionError = ignoreDataConversionError;
     this._headerPresentInFirstRow   = headerPresentInFirstRow;
     this._ignoreEmptyFile           = ignoreEmptyFile;
     this._ignoreColumnCountMismatch = ignoreColumnCountMismatch;
     _mustMatchExpectedHeader        = headerPresentInFirstRow != false && _mustMatchExpectedHeader;
 }
Exemple #2
0
 /// <summary>
 /// Constructs the Csv to Object reader instance.  Most of the parameters are optional parameters
 /// with default value.  Override the default value with the custom values
 /// </summary>
 /// <param name="fileContentLines">Content of .csv/txt file in a string array</param>
 /// <param name="mapper">instance of Csv File to Domain object mapper <see cref="CsvToObjectMapper{T}"/></param>
 /// <param name="loggerFactory"></param>
 /// <param name="headerPresentInFirstRow">Does this csv/text file has header row in first line?[default=true]</param>
 /// <param name="mustMatchExpectedHeader">Should this csv file headers match with the header provided in mapper?[default=true]</param>
 /// <param name="ignoreEmptyFile">should empty file be ignored and not marked as error?[default=true]</param>
 /// <param name="ignoreColumnCountMismatch">Should ignore the additional columns if present and not report error?[default=true]</param>
 /// <param name="ignoreDataConversionError">Should ignore the rows failing because of schema/data conversion issues?[default=true]</param>
 public CsvToObjectReader(
     string[] fileContentLines,
     CsvToObjectMapper <T> mapper,
     ILoggerFactory loggerFactory,
     bool headerPresentInFirstRow   = true,
     bool mustMatchExpectedHeader   = true,
     bool ignoreEmptyFile           = true,
     bool ignoreColumnCountMismatch = true,
     bool ignoreDataConversionError = true
     )
 {
     /*
      * Initialize all the initial configuration settings
      */
     this._csvContentLines           = fileContentLines;
     this._mapper                    = mapper;
     this._ignoreDataConversionError = ignoreDataConversionError;
     this._ignoreEmptyFile           = ignoreEmptyFile;
     this._ignoreColumnCountMismatch = ignoreColumnCountMismatch;
     this._logger                    = loggerFactory.CreateLogger <CsvToObjectReader <T> >();
 }
 /// <summary>
 /// Constructs the Csv to Object reader instance.  Most of the parameters are optional parameters
 /// with default value.  Override the default value with the custom values
 /// </summary>
 /// <param name="fileContentLines">Content of .csv/txt file in a string array</param>
 /// <param name="mapper">instance of Csv File to Domain object mapper <see cref="CsvToObjectMapper{T}"/></param>
 /// <param name="headerPresentInFirstRow">Does this csv/text file has header row in first line?[default=true]</param>
 /// <param name="mustMatchExpectedHeader">Should this csv file headers match with the header provided in mapper?[default=true]</param>
 /// <param name="ignoreEmptyFile">should empty file be ignored and not marked as error?[default=true]</param>
 /// <param name="ignoreColumnCountMismatch">Should ignore the additional columns if present and not report error?[default=true]</param>
 /// <param name="ignoreDataConversionError">Should ignore the rows failing because of schema/data conversion issues?[default=true]</param>
 public CsvToObjectReader(
     string[] fileContentLines,
     CsvToObjectMapper <T> mapper,
     bool headerPresentInFirstRow   = true,
     bool mustMatchExpectedHeader   = true,
     bool ignoreEmptyFile           = true,
     bool ignoreColumnCountMismatch = true,
     bool ignoreDataConversionError = true
     )
 {
     /*
      * Initialize all the initial configuration settings
      */
     this._csvContentLines         = fileContentLines;
     this._mustMatchExpectedHeader = mustMatchExpectedHeader;
     this._mapper = mapper;
     this._ignoreDataConversionError = ignoreDataConversionError;
     this._headerPresentInFirstRow   = headerPresentInFirstRow;
     this._ignoreEmptyFile           = ignoreEmptyFile;
     this._ignoreColumnCountMismatch = ignoreColumnCountMismatch;
     _mustMatchExpectedHeader        = headerPresentInFirstRow != false && _mustMatchExpectedHeader;
 }
Exemple #4
0
 /// <summary>
 /// Constructs the Csv to Object reader instance.  Most of the parameters are optional parameters
 /// with default value.  Override the default value with the custom values
 /// </summary>
 /// <param name="mapper">instance of Csv File to Domain object mapper <see cref="CsvToObjectMapper{T}"/></param>
 /// <param name="loggerFactory"></param>
 /// <param name="fileContent">Content of .csv/txt file</param>
 /// <param name="ignoreEmptyFile">should empty file be ignored and not marked as error?[default=true]</param>
 /// <param name="ignoreColumnCountMismatch">Should ignore the additional columns if present and not report error?[default=true]</param>
 /// <param name="ignoreDataConversionError">Should ignore the rows failing because of schema/data conversion issues?[default=true]</param>
 public CsvToObjectReader(
     CsvToObjectMapper <T> mapper,
     ILoggerFactory loggerFactory,
     string fileContent,
     bool ignoreEmptyFile           = true,
     bool ignoreColumnCountMismatch = true,
     bool ignoreDataConversionError = true
     )
 {
     /*
      * Initialize all the initial configuration settings
      */
     this._csvContentLines = fileContent?.Split(
         new[] { Environment.NewLine },
         StringSplitOptions.None
         );
     this._mapper = mapper;
     this._ignoreDataConversionError = ignoreDataConversionError;
     this._ignoreEmptyFile           = ignoreEmptyFile;
     this._ignoreColumnCountMismatch = ignoreColumnCountMismatch;
     this._logger = loggerFactory.CreateLogger <CsvToObjectReader <T> >();
 }