/// <summary> /// All other services will be resolved from ServiceProvider. /// </summary> public MvcMiddleware( MvcOptions mvcOptions, IUseMvcBuilder useMvcBuilder ) { useMvcBuilder.Routers = useMvcBuilder.Routers ?? new List <IRouter>(); useMvcBuilder.ModelBinders = useMvcBuilder.ModelBinders ?? new List <IModelBinder>(); _mvcOptions = (MvcOptions)mvcOptions.Clone(); var serv = useMvcBuilder.ServiceProvider; _mainRouter = new MainRouter(useMvcBuilder.Routers); _contextPreparer = serv.GetRequiredService <IContextPreparer>(); //Controllers. var controllers = useMvcBuilder.Controllers ?? new List <Type>(); var startupRoutes = useMvcBuilder.GetRoutes(); _globalSearchBag = CreateGlobalSearchBag(serv, startupRoutes, controllers); var mainModelBinder = new MainModelBinder(useMvcBuilder.ModelBinders); //Init services bus. _servicesBus = serv.GetRequiredService <ServicesBus>(); var outerMiddlewaresInformer = new OuterMiddlewaresInformer(_mainRouter); var mvcFeatures = new MvcFeatures(); _servicesBus.Init( _mainRouter, outerMiddlewaresInformer, mvcFeatures, mainModelBinder ); }
/// <summary> /// Invoked in <see cref="MvcMiddleware"/> /// </summary> public void Init( MainRouter mainRouter, IOuterMiddlewaresInformer outerMiddlewaresInformer, IMvcFeatures mvcFeatures, MainModelBinder mainModelBinder ) { MainRouter = mainRouter; OuterMiddlewaresInformer = outerMiddlewaresInformer; MvcFeatures = mvcFeatures; MainModelBinder = mainModelBinder; }