Esempio n. 1
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.AddControllers().AddFluentValidation();

            services.AddDbContext <ApplicationDbContext>(opt =>
            {
                opt.UseSqlServer(_configuration.GetConnectionString("DefaultConnectionString"),
                                 x => x.MigrationsAssembly("DarkAdminPanel.DataAccess"));
            });

            services.AddSingleton(AutoMapperConfig.CreateMapper());

            // Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerGen();

            //Adding Identity Server
            IdentityServerModule.Load(services);

            //Adding JWT
            JwtModule.Load(services, _configuration);

            //Adding Validator
            ValidatorModule.Load(services);

            //Configure DI for application services
            LogicModule.Load(services);
        }
Esempio n. 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.AddControllersWithViews();

            services.AddMemoryCache();
            services.AddSession();
            services.AddHttpContextAccessor();

            // Auto Mapper Configurations
            services.AddSingleton(AutoMapperConfig.CreateMapper());

            //Configure DI for application services
            LogicModule.Load(services);

            //Adding Jwt module
            JwtModule.Load(services, _configuration);

            //Adding HttpClient module
            HttpClientModule.Load(services);
        }
        /// <summary>
        /// 增加JWT模块
        /// </summary>
        /// <param name="serviceCollection"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static IServiceCollection AddJwtModule(this IServiceCollection serviceCollection, Action <JwtOptions> action)
        {
            var module = new JwtModule(action);

            return(serviceCollection.AddModule <JwtModule>(module));
        }