예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(
                options =>
                options
                .UseLazyLoadingProxies()
                .EnableSensitiveDataLogging()
                .UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddDefaultIdentity <ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
            .AddEntityFrameworkStores <ApplicationDbContext>();
            services.AddControllersWithViews();

            services.AddTransient <IEmailSender, EmailSender>();
            services.Configure <MailSettings>(Configuration.GetSection("MailSettings"));

            IdentityConfiguration.ConfigureIdentity(services);
            services.AddRazorPages();
            CustomDIMappings.AddApplicationDIMappings(services);
            services.AddControllers(config =>
            {
                var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
                config.Filters.Add(new AuthorizeFilter(policy));
            });
        }
예제 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <Context>(options =>
                                            options.UseSqlServer(Configuration.GetConnectionString("Connection")));

            IdentityConfiguration.AddIdentity(services);
            services.AddCors();
            services.AddMvc();


            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton <UrlResolver>();
            IdentityConfiguration.ConfigureIdentity(services);

            services.AddSingleton(_ => Configuration as IConfigurationRoot);
            services.AddScoped <PasswordHasher <User> >();
            services.AddScoped <IUserRepository, UserRepository>();
            services.AddScoped <IEventRepository, EventRepository>();
            services.AddScoped <IEventService, EventService>();
            services.AddScoped <IStatusService, StatusService>();
            services.AddScoped <IStatusRepository, StatusRepository>();
            services.AddScoped <ICommentRepository, CommentRepository>();
            services.AddScoped <ICommentService, CommentService>();
            services.AddScoped <IUserService, UserService>();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "CoolMeet API", Version = "v1"
                });
            });
            services.AddAutoMapper();

            JwtConfiguration.AddJwtAuthorization(Configuration, services);
        }
예제 #3
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddCors();
     ApplicationInsightsTelemetryConfiguration.ConfigureApplicationInsightsTelemetry(services, Configuration);
     FiltersConfiguration.ConfigureFilter(services);
     DatabaseConfiguration.ConfigureDatabae(services, Configuration);
     IdentityConfiguration.ConfigureIdentity(services);
     JwtConfiguration.ConfigureJwtAuthService(services, Configuration);
     DependencyInjectorConfiguration.ConfigureDependencyInjector(services, Configuration);
 }
예제 #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ExampleContext>(
                options => { options.UseSqlServer(Configuration.GetConnectionString("LocalDb")); });

            IdentityConfiguration.AddIdentity(services);
            services.AddCors();
            services.AddMvc();
            IdentityConfiguration.ConfigureIdentity(services);
            services.AddSingleton(sp => AutoMapperConfig.Initialize());
            services.AddSingleton(_ => Configuration as IConfigurationRoot);
            services.AddScoped <PasswordHasher <User> >();
            services.AddScoped <IAuthService, AuthService>();
            JwtConfiguration.AddJwtAuthorization(Configuration, services);
        }
예제 #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMemoryCache();
            services.AddDbContext <PgsKanbanContext>(options =>
                                                     options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            IdentityConfiguration.AddIdentity(services);
            SwaggerConfiguration.ConfigureSwagger(services);
            SignalRConfiguration.AddSignalR(services);
            MvcConfiguration.AddMvc(services);
            IdentityConfiguration.ConfigureIdentity(services);
            CorsConfiguration.AddCors(services);
            OptionsRegistration.Configure(Configuration, services);
            services.AddSingleton <IMapper>(sp => AutoMapperConfig.Initialize());
            JwtConfiguration.AddJwtAuthorization(Configuration, services);

            return(DependencyRegistration.Register(Configuration, services));
        }