コード例 #1
0
        public static IServiceCollection AddCloudinary(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddSingleton(x => CloudinaryFactory.GetInstance(configuration))
            .AddSingleton <ICloudinaryHelper, CloudinaryHelper>()
            .AddTransient <IApplicationCloudinary, ApplicationCloudinary>();

            return(services);
        }
コード例 #2
0
        public static IServiceCollection AddInfrastructureLayer(this IServiceCollection services, IConfiguration configuration)
        {
            configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));

            services.AddTransient <IDateTime, MachineDateTime>();
            services.AddScoped <INotifyService, UserNotificationHub>();
            services.AddTransient <IEmailSender, BeslMessageSender>();
            services.AddTransient <ISmsSender, BeslMessageSender>();
            services.AddScoped <IUserAccessor, UserAccessor>();
            services.AddSingleton(x => CloudinaryFactory.GetInstance(configuration));
            services.AddTransient <ICloudinaryHelper, CloudinaryHelper>();

            return(services);
        }
コード例 #3
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddApplicationInsightsTelemetry();

            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(
                                                             this.Configuration
                                                             .GetConnectionString(DbConnectionStringHandler.GetConnectionStringNameForCurrentOS())));

            services.AddDbContext <IApplicationDbContext, ApplicationDbContext>(options =>
                                                                                options.UseSqlServer(
                                                                                    this.Configuration
                                                                                    .GetConnectionString(DbConnectionStringHandler.GetConnectionStringNameForCurrentOS())));

            services.AddTransient <IUserStore <Player>, ApplicationUserStore>();
            services.AddTransient <IRoleStore <PlayerRole>, ApplicationRoleStore>();

            services.AddIdentity <Player, PlayerRole>(
                opt =>
            {
                opt.Password.RequiredLength         = 6;
                opt.Password.RequireDigit           = true;
                opt.Password.RequireLowercase       = true;
                opt.Password.RequireUppercase       = true;
                opt.Password.RequireNonAlphanumeric = false;
            })
            .AddUserStore <ApplicationUserStore>()
            .AddRoleStore <ApplicationRoleStore>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders()
            .AddDefaultUI();

            services.AddAuthentication().AddSteam();

            services.AddAutoMapper(new Assembly[] { typeof(AutoMapperProfile).Assembly });

            services.AddRazorPages();
            services.AddControllersWithViews()
            .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <ApplicationDependencyInjectionHelper>())
            .AddRazorRuntimeCompilation();

            services.AddMediatR(typeof(ApplicationDependencyInjectionHelper).Assembly);

            services.AddTransient <IDateTime, MachineDateTime>();

            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(RequestPerformanceBehaviour <,>));
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(CustomExceptionNotificationBehaviour <,>));

            services.AddScoped <IFileValidate, GameImageFileValidate>();
            services.AddScoped <INotifyService, UserNotificationHub>();

            services.AddScoped(typeof(IDeletableEntityRepository <>), typeof(EfDeletableEntityRepository <>));
            services.AddScoped(typeof(IRepository <>), typeof(EfRepository <>));

            services.AddSignalR();
            services.AddHttpContextAccessor();

            services.AddHangfire(cfg => cfg.UseSqlServerStorage(
                                     this.Configuration.GetConnectionString(DbConnectionStringHandler.GetHangfireConnectionStringNameForCurrentOS())));

            services.AddTransient <CheckForVACBans>();

            services.AddTransient <IEmailSender, BeslMessageSender>();
            services.AddTransient <ISmsSender, BeslMessageSender>();

            services.AddScoped <IUserAccessor, UserAccessor>();

            services.AddSingleton(x => CloudinaryFactory.GetInstance(this.Configuration));
            services.AddTransient <ICloudinaryHelper, CloudinaryHelper>();

            services.Configure <RedisConfigurationOptions>(Configuration.GetSection("Redis"));
            services.AddTransient(typeof(IRedisService <>), typeof(RedisService <>));
        }