Пример #1
0
        private static void RegisterServices(DbToFileConfig fileConfig)
        {
            var services = new ServiceCollection();

            services.AddSingleton <IDatabaseExtractor>(x => new SqlServerExtractor(fileConfig.ConnectionString));
            services.AddSingleton <IFileWriterFactory, FileWriterFactory>();
            _serviceProvider = services.BuildServiceProvider(true);
        }
Пример #2
0
        private static void LaunchProcessor(DbToFileConfig fileConfig)
        {
            IDatabaseExtractor databaseExtractor = _serviceProvider.GetService <IDatabaseExtractor>();
            IFileWriter        fileWriter        = _serviceProvider.GetService <IFileWriterFactory>().Create(fileConfig.OutputFormat);
            var processor = new Processor(databaseExtractor, fileWriter);

            processor.Process(fileConfig.TableGroups, fileConfig.FileOutputName);
        }
Пример #3
0
        static void Main(string[] args)
        {
            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json", true, true)
                                    .Build();

            DbToFileConfig fileConfig = new DbToFileConfig();

            config.GetSection("DbToFileConfig").Bind(fileConfig);

            RegisterServices(fileConfig);
            LaunchProcessor(fileConfig);
        }