Esempio n. 1
0
        public IDataImporter Build()
        {
            var parserFactory = new DefaultCSVParserFactory();

            var testImporter = new SimpleCSVDataImporter(ResultLevel.ERROR, 4);

            var extensionValidationRule = new CSVFileNameExtensionMatchValidationRule(".dat", false);

            testImporter.AddValidationRule(extensionValidationRule);

            var stationNameMatchRule = new CellValueMatchCriteriaValidationRule(new CSVDataSourceLocation(0, 0), new DefaultCSVParserFactory(), typeof(string), new RegexCriteria("^TOA5$"));

            testImporter.AddValidationRule(stationNameMatchRule);


            var dateTimeFieldExtractConfiguration = new SimpleCSVExtractConfiguration(0,
                                                                                      "DateTime",
                                                                                      parserFactory.GetCellParser(typeof(DateTime)),
                                                                                      new SimpleValueAssigner(),
                                                                                      typeof(DateTime));

            var waterLevelExtractConfiguration = new SimpleCSVExtractConfiguration(2,
                                                                                   "WaterLevel",
                                                                                   parserFactory.GetCellParser(typeof(double?)),
                                                                                   new SimpleValueAssigner(),
                                                                                   typeof(double?));

            var waterTemperatureExtractConfiguration = new SimpleCSVExtractConfiguration(3,
                                                                                         "WaterTemperature",
                                                                                         parserFactory.GetCellParser(typeof(double?)),
                                                                                         new SimpleValueAssigner(),
                                                                                         typeof(double?));


            testImporter.AddExtractConfiguration(dateTimeFieldExtractConfiguration);
            testImporter.AddExtractConfiguration(waterLevelExtractConfiguration);
            testImporter.AddExtractConfiguration(waterTemperatureExtractConfiguration);

            return(testImporter);
        }
        public IDataImporter Build()
        {
            var parserFactory = new DefaultCSVParserFactory();

            var testImporter = new SimpleCSVDataImporter(ResultLevel.ERROR, 4);

            var extensionValidationRule = new CSVFileNameExtensionMatchValidationRule(".dat", false);
            testImporter.AddValidationRule(extensionValidationRule);

            var stationNameMatchRule = new CellValueMatchCriteriaValidationRule(new CSVDataSourceLocation(0, 0), new DefaultCSVParserFactory(), typeof(string), new RegexCriteria("^TOA5$"));
            testImporter.AddValidationRule(stationNameMatchRule);


            var dateTimeFieldExtractConfiguration = new SimpleCSVExtractConfiguration(0,
                                                                                      "DateTime", 
                                                                                      parserFactory.GetCellParser(typeof(DateTime)), 
                                                                                      new SimpleValueAssigner(), 
                                                                                      typeof(DateTime));

            var waterLevelExtractConfiguration = new SimpleCSVExtractConfiguration(2,
                                                                                   "WaterLevel",
                                                                                   parserFactory.GetCellParser(typeof(double?)),
                                                                                   new SimpleValueAssigner(),
                                                                                   typeof(double?));

            var waterTemperatureExtractConfiguration = new SimpleCSVExtractConfiguration(3,
                                                                                         "WaterTemperature",
                                                                                         parserFactory.GetCellParser(typeof(double?)),
                                                                                         new SimpleValueAssigner(),
                                                                                         typeof(double?));


            testImporter.AddExtractConfiguration(dateTimeFieldExtractConfiguration);
            testImporter.AddExtractConfiguration(waterLevelExtractConfiguration);
            testImporter.AddExtractConfiguration(waterTemperatureExtractConfiguration);

            return testImporter;
        }