Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="services"></param>
        public void ConfigureServices(IServiceCollection services)
        {
            SwaggerConfiguration.AddService(services);
            DbContextExtension.AddService(services, Configuration);
            CorsExtension.AddService(services);
            RouteExtension.AddService(services);
            RouteAnalyzerExtension.AddService(services);
            services.AddMemoryCache();
            services.AddHttpContextAccessor();
            services.AddSingleton <IActionContextAccessor, ActionContextAccessor>();

            try
            {
#pragma warning disable 618
                AuthenticationConfiguration.AddService(services, Configuration);
                services.AddAutoMapper();
#pragma warning disable 618
            }
            catch
            {
            }

            WebEncoderConfiguration.AddService(services);
            ValidateConfiguration.AddService(services);
            JsonExtension.AddService(services);
            SetCompatibilityVersionExtension.AddService(services);
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            SwaggerConfiguration.AddService(services);
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .AddApplicationPart(typeof(ValuesController).Assembly);
            //内存数据库
            //ConfigureInMemoryDatabases(services);
            //正式库

            ConfigureProductionServices(services);

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddAutoMapperSetup();
            //services.AddMediatR(typeof(Startup).GetTypeInfo().Assembly);
            //添加缓存
            services.AddMemoryCache();
            services.AddHttpClient();
            services.AddNativeInjectorBootStrapper();
        }