mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	IOcelotBuilder opens the IMvcCoreBuilder property for easy customization (#790)
* IOcelotBuilder opens the IMvcCoreBuilder property for easy customization * Adjustment code
This commit is contained in:
		@@ -12,6 +12,8 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        IConfiguration Configuration { get; }
 | 
					        IConfiguration Configuration { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        IMvcCoreBuilder MvcCoreBuilder { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        IOcelotBuilder AddDelegatingHandler<T>(bool global = false)
 | 
					        IOcelotBuilder AddDelegatingHandler<T>(bool global = false)
 | 
				
			||||||
            where T : DelegatingHandler;
 | 
					            where T : DelegatingHandler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,6 +42,7 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        public IServiceCollection Services { get; }
 | 
					        public IServiceCollection Services { get; }
 | 
				
			||||||
        public IConfiguration Configuration { get; }
 | 
					        public IConfiguration Configuration { get; }
 | 
				
			||||||
 | 
					        public IMvcCoreBuilder MvcCoreBuilder { get; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public OcelotBuilder(IServiceCollection services, IConfiguration configurationRoot)
 | 
					        public OcelotBuilder(IServiceCollection services, IConfiguration configurationRoot)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -133,7 +134,7 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
            //add asp.net services..
 | 
					            //add asp.net services..
 | 
				
			||||||
            var assembly = typeof(FileConfigurationController).GetTypeInfo().Assembly;
 | 
					            var assembly = typeof(FileConfigurationController).GetTypeInfo().Assembly;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Services.AddMvcCore()
 | 
					            this.MvcCoreBuilder = Services.AddMvcCore()
 | 
				
			||||||
                  .AddApplicationPart(assembly)
 | 
					                  .AddApplicationPart(assembly)
 | 
				
			||||||
                  .AddControllersAsServices()
 | 
					                  .AddControllersAsServices()
 | 
				
			||||||
                  .AddAuthorization()
 | 
					                  .AddAuthorization()
 | 
				
			||||||
@@ -144,6 +145,7 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
            Services.AddWebEncoders();
 | 
					            Services.AddWebEncoders();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public IOcelotBuilder AddSingletonDefinedAggregator<T>()
 | 
					        public IOcelotBuilder AddSingletonDefinedAggregator<T>()
 | 
				
			||||||
            where T : class, IDefinedAggregator
 | 
					            where T : class, IDefinedAggregator
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -170,7 +172,7 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
            if(global)
 | 
					            if(global)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Services.AddTransient<THandler>();
 | 
					                Services.AddTransient<THandler>();
 | 
				
			||||||
                Services.AddTransient<GlobalDelegatingHandler>(s => {
 | 
					                Services.AddTransient<GlobalDelegatingHandler>(s =>{
 | 
				
			||||||
                    var service = s.GetService<THandler>();
 | 
					                    var service = s.GetService<THandler>();
 | 
				
			||||||
                    return new GlobalDelegatingHandler(service);
 | 
					                    return new GlobalDelegatingHandler(service);
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user