예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var        voteNotifier = new UpvoteNotifier();
            IBotConfig botConfig    = BotConfig.GetConfig();

            services.AddControllers();
            services.AddOptions();
            services.AddScoped <KaguyaDb>();
            services.AddScoped <KaguyaApiConfig>();
            services.AddSingleton(botConfig);
            services.AddSingleton(new KaguyaDbSettings(new KaguyaApiConfig(botConfig)));
            services.AddSingleton(voteNotifier);

            var dbSettings = services.BuildServiceProvider().GetRequiredService <KaguyaDbSettings>();

            services.AddCors(options =>
            {
                options.AddPolicy("AllowAll",
                                  builder =>
                {
                    builder
                    .AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader();
                });
            });

            // Initialize connection to database.
            DataConnection.DefaultSettings = dbSettings;
            LinqToDB.Common.Configuration.Linq.AllowMultipleQuery = true;
        }
예제 #2
0
 public TopGgController(IBotConfig cfg, KaguyaDb db, UpvoteNotifier uvNotifier)
 {
     _cfg        = cfg;
     _db         = db;
     _uvNotifier = uvNotifier;
 }