protected private ActionEndpointDataSourceBase CreateDataSource(IActionDescriptorCollectionProvider actions = null) { if (actions == null) { actions = new DefaultActionDescriptorCollectionProvider( Array.Empty <IActionDescriptorProvider>(), Array.Empty <IActionDescriptorChangeProvider>()); } var services = new ServiceCollection(); services.AddSingleton(actions); var routeOptionsSetup = new MvcCoreRouteOptionsSetup(); services.Configure <RouteOptions>(routeOptionsSetup.Configure); services.AddRouting(options => { options.ConstraintMap["upper-case"] = typeof(UpperCaseParameterTransform); }); var serviceProvider = services.BuildServiceProvider(); var endpointFactory = new ActionEndpointFactory(serviceProvider.GetRequiredService <RoutePatternTransformer>(), Enumerable.Empty <IRequestDelegateFactory>()); return(CreateDataSource(actions, endpointFactory)); }
public ActionEndpointDataSource(IActionDescriptorCollectionProvider actions, ActionEndpointFactory endpointFactory) : base(actions) { _endpointFactory = endpointFactory; _routes = new List <ConventionalRouteEntry>(); // IMPORTANT: this needs to be the last thing we do in the constructor. // Change notifications can happen immediately! Subscribe(); }
public ActionEndpointFactoryTest() { var serviceCollection = new ServiceCollection(); var routeOptionsSetup = new MvcCoreRouteOptionsSetup(); serviceCollection.Configure <RouteOptions>(routeOptionsSetup.Configure); serviceCollection.AddRouting(options => { options.ConstraintMap["upper-case"] = typeof(UpperCaseParameterTransform); }); Services = serviceCollection.BuildServiceProvider(); Factory = new ActionEndpointFactory(Services.GetRequiredService <RoutePatternTransformer>(), Enumerable.Empty <IRequestDelegateFactory>()); }
public ControllerActionEndpointDataSource( IActionDescriptorCollectionProvider actions, ActionEndpointFactory endpointFactory, OrderedEndpointsSequenceProvider orderSequence) : base(actions) { _endpointFactory = endpointFactory; _orderSequence = orderSequence; _routes = new List <ConventionalRouteEntry>(); DefaultBuilder = new ControllerActionEndpointConventionBuilder(Lock, Conventions); // IMPORTANT: this needs to be the last thing we do in the constructor. // Change notifications can happen immediately! Subscribe(); }
public ActionEndpointFactoryTest() { var serviceCollection = new ServiceCollection(); var routeOptionsSetup = new MvcCoreRouteOptionsSetup(); serviceCollection.Configure <RouteOptions>(routeOptionsSetup.Configure); serviceCollection.AddRouting(options => { options.ConstraintMap["upper-case"] = typeof(UpperCaseParameterTransform); }); Services = serviceCollection.BuildServiceProvider(); InvokerFactory = new Mock <IActionInvokerFactory>(MockBehavior.Strict); Factory = new ActionEndpointFactory( Services.GetRequiredService <RoutePatternTransformer>(), new MvcEndpointInvokerFactory(InvokerFactory.Object)); }
public ControllerActionEndpointDataSource( IActionDescriptorCollectionProvider actions, ActionEndpointFactory endpointFactory) : base(actions) { _endpointFactory = endpointFactory; _routes = new List <ConventionalRouteEntry>(); // In traditional conventional routing setup, the routes defined by a user have a order // defined by how they are added into the list. We would like to maintain the same order when building // up the endpoints too. // // Start with an order of '1' for conventional routes as attribute routes have a default order of '0'. // This is for scenarios dealing with migrating existing Router based code to Endpoint Routing world. _order = 1; // IMPORTANT: this needs to be the last thing we do in the constructor. // Change notifications can happen immediately! Subscribe(); }
public void RequestDelegateFactoryWorks() { // Arrange var values = new { controller = "TestController", action = "TestAction", page = (string)null }; var action = CreateActionDescriptor(values, "{controller}/{action}/{page}"); action.AttributeRouteInfo.Name = "Test"; RequestDelegate del = context => Task.CompletedTask; var requestDelegateFactory = new Mock <IRequestDelegateFactory>(); requestDelegateFactory.Setup(m => m.CreateRequestDelegate(action, It.IsAny <RouteValueDictionary>())).Returns(del); // Act var factory = new ActionEndpointFactory(Services.GetRequiredService <RoutePatternTransformer>(), new[] { requestDelegateFactory.Object }); var endpoints = new List <Endpoint>(); factory.AddEndpoints(endpoints, new HashSet <string>(), action, Array.Empty <ConventionalRouteEntry>(), Array.Empty <Action <EndpointBuilder> >(), createInertEndpoints: false); var endpoint = Assert.IsType <RouteEndpoint>(Assert.Single(endpoints)); // Assert Assert.Same(del, endpoint.RequestDelegate); }
private protected override ActionEndpointDataSourceBase CreateDataSource(IActionDescriptorCollectionProvider actions, ActionEndpointFactory endpointFactory) { return(new ControllerActionEndpointDataSource(actions, endpointFactory)); }
private protected override ActionEndpointDataSourceBase CreateDataSource(IActionDescriptorCollectionProvider actions, ActionEndpointFactory endpointFactory) { return(new ControllerActionEndpointDataSource( new ControllerActionEndpointDataSourceIdProvider(), actions, endpointFactory, new OrderedEndpointsSequenceProvider())); }
protected private abstract ActionEndpointDataSourceBase CreateDataSource(IActionDescriptorCollectionProvider actions, ActionEndpointFactory endpointFactory);