コード例 #1
0
        public static void ConfigureApplicationServices(IServiceCollection services, UpriseApiConfiguration configuration)
        {
            services.AddSingleton(configuration);

            services.AddDbContext <UpriseContext>
            (
                options => options
                .UseLazyLoadingProxies()
                .UseInMemoryDatabase(databaseName: "Uprise")
            );

            services.AddScoped <ICurrentUserAccessor, CurrentUserAccessor>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.AddSingleton(x => new AzureBlobService(configuration.Azure.ConnectionString));

            services.AddScoped <CampaignRepository>();
            services.AddScoped <ContactRepository>();
            services.AddScoped <PostRepository>();

            services.AddScoped <UsersService>();
            services.AddScoped <IdentityHelper>();

            services.AddScoped <SendgridService>();
        }
コード例 #2
0
 public SendgridService
 (
     UpriseApiConfiguration configuration,
     UpriseContext databaseContext,
     UsersService usersService
 )
 {
     _databaseContext = databaseContext ?? throw new ArgumentNullException(nameof(databaseContext));
     _usersService    = usersService ?? throw new ArgumentNullException(nameof(usersService));
     _apiKey          = configuration?.Sendgrid?.ApiKey ?? throw new ArgumentNullException("apiKey");
     _sendEmails      = configuration?.Sendgrid?.SendEmails ?? false;
 }