public static IList<AddressPartReduction> LoadFromCSV(string path) { var list = new List<AddressPartReduction>(); var dataSource = new CsvDataSource(AddressLoader.Log); using (var sr = new StreamReader(path)) { var reader = dataSource.GetReader(sr); IEnumerable<AddressPartReduction> records = reader.GetRecords<AddressPartReduction>(); list.AddRange(records); } return list; }
private static Dictionary<int, Dictionary<string, AddressPartReduction>> LoadReductionInternal() { var assem = typeof(AddressParserTests).Assembly; var resource = assem.GetManifestResourceStream("RUAddress.Tests.Resources.SOCRBASE.csv"); var dataSource = new CsvDataSource(Log); using (var sr = new StreamReader(resource)) { var reader = dataSource.GetReader(sr); IEnumerable<AddressPartReduction> records = reader.GetRecords<AddressPartReduction>(); var reductions = new Dictionary<int, Dictionary<string, AddressPartReduction>>(); foreach (var d in records) { if (!reductions.ContainsKey(d.Level)) { reductions.Add(d.Level, new Dictionary<string, AddressPartReduction>()); } var dict = reductions[d.Level]; var reduction = d.Short.ToLower(); dict.Add(reduction, d); } return reductions; } }