public Dictionary <string, CensusDTO> LoadCSVCensusData(CensusAnalyser.Country country, string csvFilePath, string headers) { return(country switch { (CensusAnalyser.Country.INDIA) => new IndianStateCensusAdapter().LoadCensusData(csvFilePath, headers), (CensusAnalyser.Country.US) => new USCensusAdapter().LoadCensusData(csvFilePath, headers), _ => throw new CensusAnalyserException("No such country found", CensusAnalyserException.ExceptionType.NO_SUCH_COUNTRY), });
public Dictionary <string, CensusDTO> LoadCsvData(CensusAnalyser.Country country, string csvFilePath, string dataHeaders) { switch (country) { case (CensusAnalyser.Country.INDIA): return(new IndianCensusAdapter().LoadCensusData(csvFilePath, dataHeaders)); default: throw new CensusAnalyserException("No Such Country", CensusAnalyserException.ExceptionType.NO_SUCH_COUNTRY); } }
public Dictionary <string, CensusDTO> LoadCsvData(CensusAnalyser.Country country, string csvFilePath, string dataHeaders) { switch (country) { case (CensusAnalyser.Country.INDIA): return(new IndiaCensusAdapter().LoadCensusData(csvFilePath, dataHeaders)); default: throw new CensusAnalyserException("Country which is given is invalid", CensusAnalyserException.ExceptionType.INVALID_COUNTRY); } }
/// <summary> /// This Method check the Country and According to country that Adapter Class is return /// </summary> /// <param name="country">It contains the country name</param> /// <param name="csvFilePath">It contains the CSV File Path</param> /// <returns>It returns the Adapter Class Based On Country</returns> public List <CensusDAO> LoadCensusData(CensusAnalyser.Country country, string csvFilePath) { // Check the country is Equal to India or US if (country.Equals(CensusAnalyser.Country.INDIA)) { return(new IndiaCensusAdapter().LoadCensusData(csvFilePath)); } else if (country.Equals(CensusAnalyser.Country.US)) { return(new USCensusAdapter().LoadUSCensusData(csvFilePath)); } else { throw new CensusAnalyserException(CensusAnalyserException.ExceptionType.InvalidCountry, "Invalid Country"); } }
/// <summary> /// Method to return dictionary of csv data by creating object of different adapter classes according to country provided. /// </summary> /// <param name="csvFilePath">Path of csv file.</param> /// <param name="fileHeaders">Headers of Csv file.</param> /// <param name="country">Country of which the file is.</param> /// <returns>Object of Different Adapter class according to country.</returns> public static Dictionary <string, dynamic> LoadCsvData(string csvFilePath, string fileHeaders, CensusAnalyser.Country country) { switch (country) { case CensusAnalyser.Country.INDIA: return(new IndianCensusAdapter().LoadIndianCensusData(csvFilePath, fileHeaders)); case CensusAnalyser.Country.US: return(new USCensusAdapter().LoadUSCensusData(csvFilePath, fileHeaders)); default: throw new CensusAnalyserException("No Such Country", CensusAnalyserException.ExceptionType.NO_COUNTRY_FOUND); } }