コード例 #1
0
ファイル: Startup.cs プロジェクト: SebastianBienert/CoolMeet
        // 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);
        }
コード例 #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 <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);
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: mwalczynski/PGSKanban
        // 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));
        }