public MvcEndpointDataSource(
            IActionDescriptorCollectionProvider actions,
            MvcEndpointInvokerFactory invokerFactory,
            ParameterPolicyFactory parameterPolicyFactory,
            RoutePatternTransformer routePatternTransformer)
        {
            _actions                 = actions;
            _invokerFactory          = invokerFactory;
            _parameterPolicyFactory  = parameterPolicyFactory;
            _routePatternTransformer = routePatternTransformer;

            ConventionalEndpointInfos           = new List <MvcEndpointInfo>();
            AttributeRoutingConventionResolvers = new List <Func <ActionDescriptor, DefaultEndpointConventionBuilder> >();

            // IMPORTANT: this needs to be the last thing we do in the constructor. Change notifications can happen immediately!
            //
            // It's possible for someone to override the collection provider without providing
            // change notifications. If that's the case we won't process changes.
            if (actions is ActionDescriptorCollectionProvider collectionProviderWithChangeToken)
            {
                ChangeToken.OnChange(
                    () => collectionProviderWithChangeToken.GetChangeToken(),
                    UpdateEndpoints);
            }
        }
Exemplo n.º 2
0
        public MvcEndpointDataSource(IActionInvokerFactory actionInvokerFactory,
                                     IActionDescriptorProvider actionDiscriptorProvider,
                                     RoutePatternTransformer transformer)
        {
            _actionInvokerFactory = actionInvokerFactory;

            _endpoints = new Lazy <IReadOnlyList <Endpoint> >(Create());

            List <Endpoint> Create()
            {
                var Descriptors = actionDiscriptorProvider.GetActionDescriptors;

                return(Descriptors.Select(CreateEndpoint).ToList());
            }

            Endpoint CreateEndpoint(ActionDescriptor actionDiscriptor)
            {
                var routePattern    = RoutePatternFactory.Parse(actionDiscriptor.RouteInfo.Template);
                var newRoutePattern = transformer.SubstituteRequiredValues(routePattern, new Dictionary <string, string>
                {
                    ["controller"] = actionDiscriptor.ControllerName,
                    ["action"]     = actionDiscriptor.ActionName
                });

                routePattern = routePattern ?? newRoutePattern;
                var endPointBuilder = new RouteEndpointBuilder(InvokeAsync, routePattern, actionDiscriptor.RouteInfo.Order ?? 0);

                endPointBuilder.Metadata.Add(actionDiscriptor);
                return(endPointBuilder.Build());
            }
        }
Exemplo n.º 3
0
 public ControllerActionEndpointDataSource(IActionDescriptorCollectionProvider provider, RoutePatternTransformer transformer) : base(provider)
 {
     _conventionalRoutes = new List <ConventionalRouteEntry>();
     _order = 0;
     _routePatternTransformer = transformer;
     _requestDelegate         = ProcessRequestAsync;
     DefaultBuilder           = new ControllerActionEndpointConventionBuilder(base.Conventions);
 }
        public FrameworkEndpointDataSource(RoutePatternTransformer routePatternTransformer)
        {
            _routePatternTransformer = routePatternTransformer;
            _conventions             = new List <Action <EndpointModel> >();

            Patterns   = new List <RoutePattern>();
            HubMethods = new List <HubMethod>();
        }
        public ActionEndpointFactory(RoutePatternTransformer routePatternTransformer)
        {
            if (routePatternTransformer == null)
            {
                throw new ArgumentNullException(nameof(routePatternTransformer));
            }

            _routePatternTransformer = routePatternTransformer;
        }
Exemplo n.º 6
0
        public ActionEndpointFactory(RoutePatternTransformer routePatternTransformer)
        {
            if (routePatternTransformer == null)
            {
                throw new ArgumentNullException(nameof(routePatternTransformer));
            }

            _routePatternTransformer = routePatternTransformer;
            _requestDelegate         = CreateRequestDelegate();
        }
    public ActionEndpointFactory(RoutePatternTransformer routePatternTransformer, IEnumerable <IRequestDelegateFactory> requestDelegateFactories)
    {
        if (routePatternTransformer == null)
        {
            throw new ArgumentNullException(nameof(routePatternTransformer));
        }

        _routePatternTransformer  = routePatternTransformer;
        _requestDelegate          = CreateRequestDelegate();
        _requestDelegateFactories = requestDelegateFactories.ToArray();
    }
Exemplo n.º 8
0
        public ActionEndpointFactory(
            RoutePatternTransformer routePatternTransformer,
            MvcEndpointInvokerFactory invokerFactory)
        {
            if (routePatternTransformer == null)
            {
                throw new ArgumentNullException(nameof(routePatternTransformer));
            }

            if (invokerFactory == null)
            {
                throw new ArgumentNullException(nameof(invokerFactory));
            }

            _routePatternTransformer = routePatternTransformer;
            _invokerFactory          = invokerFactory;
        }