Exemplo n.º 1
0
        private ActionDescriptor InvokeActionSelector(RouteContext context)
        {
            var actionDescriptorProvider = GetActionDescriptorProvider();

            var serviceContainer = new ServiceCollection();
            var list             = new List <IActionDescriptorProvider>()
            {
                actionDescriptorProvider,
            };

            serviceContainer.AddSingleton(typeof(IEnumerable <IActionDescriptorProvider>), list);

            var actionDescriptorCollectionProvider = new ActionDescriptorCollectionProvider(
                serviceContainer.BuildServiceProvider());
            var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionDescriptorCollectionProvider);

            var actionConstraintProviders = new[]
            {
                new DefaultActionConstraintProvider(),
            };

            var defaultActionSelector = new ActionSelector(
                decisionTreeProvider,
                GetActionConstraintCache(actionConstraintProviders),
                NullLoggerFactory.Instance);

            return(defaultActionSelector.Select(context));
        }
Exemplo n.º 2
0
        private ControllerActionDescriptor InvokeActionSelector(RouteContext context)
        {
            var actionDescriptorProvider           = GetActionDescriptorProvider();
            var actionDescriptorCollectionProvider = new ActionDescriptorCollectionProvider(
                new[] { actionDescriptorProvider },
                Enumerable.Empty <IActionDescriptorChangeProvider>());

            var actionConstraintProviders = new[]
            {
                new DefaultActionConstraintProvider(),
            };

            var actionSelector = new ActionSelector(
                actionDescriptorCollectionProvider,
                GetActionConstraintCache(actionConstraintProviders),
                NullLoggerFactory.Instance);

            var candidates = actionSelector.SelectCandidates(context);

            return((ControllerActionDescriptor)actionSelector.SelectBestCandidate(context, candidates));
        }