[Dot Net Core](Graphic series )5. MiddleWare — UseEndpoint to Map Controller Cont.
The previous section has a little description of what DefaultActionDescriptorCollectionProvider in ControllerActionEndpointDataSource handles those things.
This section will track the main execution process.
First see the picture below:
The attribute _actionDescriptorProvider in the DefaultActionDescriptorCollectionProvider category executes ControllerActionDescriptorProvider.OnProvidersExecuting, and then executes the GetDescriptors function.
After finding the GetDescriptors function in step S3–1, the ControllerFeature category will be added through GetControllerTypes first, and then in step S3–2, the ApplicationPartManager will be obtained through the IOC mechanism. When creating a CreateProvider through the previous HostBuilder, it has been resolved and it is Singleten, so its FeatureProvider has a ControllerFeatureProvider; the other attribute is ApplicationParts, which also exists at the same time, and the assembly information of the project has been stored.
Step S3–3, call ContollerFeatureProvider.PopulateFeature to pack the Controller Type information into the ControllerFeature category. Step S3–4 sends this category to ApplicationModelFactory.CreateApplicationModel, which uses four applicationModelProviders to retrieve further controller information.
In step S3–5, the Controller Type will be passed to DefaultApplicationModelProvider.OnProviderExcuting as an object of ApplicationModelProviderContext to retrieve preliminary information such as Actions, Attributes, Filters, ControllerProperties, etc., and in step S3–6, assign the type of ControllerModel to ApplicationModelProviderContext.Result. middle.
Step S3–7 will organize more detailed information, and finally assign ApplicationModelProviderContext.Results to ControllerActionEndpointDataSource._actions.
Step S4 in the above figure is the final step of the entire UseEndpoints, and the Invoke part of the middleware category of EndpointMiddleware will be executed.
For details on how middleware will proceed, please see the instructions in the next section.