예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void   ConfigureServices(IServiceCollection services)
        {
            services.AddScoped <IUnitOfWork, UnitOfWork>();
            services.Configure <ApiBehaviorOptions>(opt =>
            {
                opt.SuppressModelStateInvalidFilter = true;
            });

            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            var mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);

            MediatRRegistration.RegisterMediatR(services);
            RepositoryRegistration.RegisterRepo(services);
            ServicesRegistration.RegisterService(services);

            services.AddTransient <IUserStore <ApplicationUser>, UserStore>();
            services.AddTransient <IRoleStore <ApplicationRole>, RoleStore>();
            services.AddIdentity <ApplicationUser, ApplicationRole>()
            .AddDefaultTokenProviders();
            services.AddControllersWithViews();
        }
예제 #2
0
파일: Startup.cs 프로젝트: ArSIlham/WebBlog
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            var mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);
            MediatRRegistration.RegisterMediatR(services);
            RepositoryRegistration.RegisterRepo(services);
            ServicesRegistration.RegisterService(services);
            services.AddScoped <IUnitOfWork, UnitOfWork>();



            services.AddDistributedMemoryCache();
            services.AddSession(options =>
            {
                options.IdleTimeout        = TimeSpan.FromSeconds(10);
                options.Cookie.HttpOnly    = true;
                options.Cookie.IsEssential = true;
            });
            services.AddControllersWithViews();
        }
 public static void RegisterDependencies(Container container)
 {
     MediatRRegistration.Register(container);
 }