Ejemplo 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 DefaultActionDescriptorCollectionProvider(
                serviceContainer.BuildServiceProvider());
            var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionDescriptorCollectionProvider);

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

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

            return(defaultActionSelector.Select(context));
        }
        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 DefaultActionDescriptorCollectionProvider(
                serviceContainer.BuildServiceProvider());
            var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionDescriptorCollectionProvider);

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

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

            return defaultActionSelector.Select(context);
        }