static void Main(string[] args) { IConfigurationRoot builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); ISettings settings = builder.GetSection("Settings").Get <Settings>(); settings.DataFileDirectory = AppDomain.CurrentDomain.BaseDirectory; settings.DataFilePath = Path.Combine(settings.DataFileDirectory, (settings.DataFileName + "." + settings.DataFileFormat)); Stopwatch stopwatch = new Stopwatch(); IDataGenerator dataGenerator; IDataParser dataParser; using var dbContext = new DatabaseContext(settings); dbContext.DropDatabase(); dataGenerator = GeneratorFactory.GetGenerator(settings); dataParser = ParserFactory.GetParser(settings); switch (settings.StartType.ToLower()) { case "p": Console.WriteLine($"Start Process"); stopwatch.Start(); StartProcess(settings); stopwatch.Stop(); break; case "m": Console.WriteLine($"Start Method"); stopwatch.Start(); dataGenerator.Generate(); stopwatch.Stop(); break; default: goto case "m"; } Console.WriteLine($"Generated data time: {stopwatch.ElapsedMilliseconds}"); stopwatch.Restart(); _customers = dataParser.Parse(); stopwatch.Stop(); Console.WriteLine($"Parsing data time: {stopwatch.ElapsedMilliseconds}"); FakeDataLoader fakeDataLoader = new FakeDataLoader(_customers, settings); stopwatch.Restart(); fakeDataLoader.LoadData(); stopwatch.Stop(); Console.WriteLine($"Load DB data time: {stopwatch.ElapsedMilliseconds}"); }
static void Main(string[] args) { if (args != null && args.Length == 1) { _dataFilePath = args[0]; } Console.WriteLine($"Loader started with process Id {Process.GetCurrentProcess().Id}..."); GenerateCustomersDataFile(); var loader = new FakeDataLoader(); loader.LoadData(); }