Beispiel #1
0
        public static AggregatedServicesBuilder AddMvc(this AggregatedServicesBuilder builder, Action <AggMvcOptions> options)
        {
            AggMvcOptions opts = new AggMvcOptions();

            options(opts);
            IServiceCollection services = builder.Services;
            //services.AddSingleton<IAggregatedServiceRegistrator>(sp=>new DefaultAggregatedServiceRegistrator(builder));
            //services.TryAddEnumerable(ServiceDescriptor.Singleton<IActionDescriptorProvider>((Func<IServiceProvider,AggActionDescriptorProvider>)(sp => new AggActionDescriptorProvider(1000,sp.GetRequiredService<IAggregatedServiceRegistrator>()))));

            //I have to force IActionDescriptorCollectionProvider to enumerate IActionDescriptorProvider s and register aggregated services. Hopefully, that won't cause an issue.
            //ActionDescriptorCollection forget=services.BuildServiceProvider().GetRequiredService<IActionDescriptorCollectionProvider>().ActionDescriptors;
            //Maybe it would be enough to call AggActionDescriptorProvider.FindAndRegister directly. How to let customize IAggregatedServiceRegistrator?
            //AggActionDescriptorProvider.FindAndRegister(forget.Items,new DefaultAggregatedServiceRegistrator(builder));

            ApplicationPartManager appPartManager    = GetServiceFromCollection <ApplicationPartManager>(services);
            ControllerFeature      controllerFeature = new ControllerFeature();

            appPartManager.PopulateFeature(controllerFeature);
            AggActionDescriptorProvider.FindAndRegister(controllerFeature.Controllers, opts.Registrator ?? new DefaultAggregatedServiceRegistrator(builder));

            return(builder);
        }
Beispiel #2
0
 public static AggregatedServicesBuilder AddMvc(this AggregatedServicesBuilder builder)
 => AddMvc(builder, options => { });