AspNet.Mvc.TypedRouting.Routing.TypedRoutingControllerModelConvention.Apply C# (CSharp) Method

Apply() public method

public Apply ( Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerModel controller ) : void
controller Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerModel
return void
        public void Apply(ControllerModel controller)
        {
            var routes = routeBuilder.GetTypedRoutes();

            if (routes.ContainsKey(controller.ControllerType))
            {
                var typedRoutes = routes[controller.ControllerType];
                foreach (var route in typedRoutes)
                {
                    var selectorModel = new SelectorModel
                    {
                        AttributeRouteModel = route
                    };

                    var selectors = controller.Selectors;

                    var action = controller.Actions.FirstOrDefault(x => x.ActionMethod == route.ActionMember);
                    if (action != null)
                    {
                        foreach (var constraint in route.Constraints)
                        {
                            selectorModel.ActionConstraints.Add(constraint);
                        }

                        selectors = action.Selectors;
                    }

                    selectors.Clear();
                    selectors.Add(selectorModel);
                }
            }
        }
    }
TypedRoutingControllerModelConvention