コード例 #1
0
        public static void Main(string[] args)
        {
            var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();

            try
            {
                var host = BuildWebHost(args);

                using (var scope = host.Services.CreateScope())
                {
                    var serviceProvider = scope.ServiceProvider;

                    Task.Run(async() =>
                    {
                        EngineCensoContextInitializer initializer = new EngineCensoContextInitializer(serviceProvider.GetService <IEngineCensoContext>(), serviceProvider.GetService <IHashingAlgorithm>());
                        await initializer.Seed(Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == EnvironmentName.Development);
                    }).Wait();
                }

                host.Run();
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception not caught");
                throw;
            }
            finally
            {
                NLog.LogManager.Shutdown();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: leafah/EngineCenso
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var serviceProvider = scope.ServiceProvider;

                Task.Run(async() =>
                {
                    EngineCensoContextInitializer initializer = new EngineCensoContextInitializer();
                    await initializer.Seed(serviceProvider.GetService <MongoConfig>());
                }).Wait();
            }

            host.Run();
        }