コード例 #1
0
 public static IHostBuilder CreateHostBuilder(string[] args) =>
 Host.CreateDefaultBuilder(args)
 .UseSystemd()
 .ConfigureServices(
     (hostContext, services) =>
 {
     DIModule.RegisterDependency(services);
     services.AddDbContext <CorrectItDbContext>(
         options => options.UseMySql(
             hostContext.Configuration.GetConnectionString("CorrectItWeb"),
             b => b.MigrationsAssembly("Infrastructure.Data.Sql")),
         optionsLifetime: ServiceLifetime.Singleton);
     services.AddHostedService <Worker>();
     services.AddMemoryCache();
 });
コード例 #2
0
ファイル: Startup.cs プロジェクト: sdlfly2000/CorrectIt
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });

            services.AddDbContext <CorrectItDbContext>(
                options =>
                options.UseMySql(
                    Configuration.GetConnectionString("CorrectItWeb"),
                    b =>
            {
                b.MigrationsAssembly("Infrastructure.Data.Sql");
            }));

            services.AddMemoryCache();

            DIModule.RegisterDependency(services);

            //CacheModule.RegisterCache(services);
        }