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

            // service container does not work quite like our built in Depenency Injection container.
            var serviceContainer = new ServiceContainer();
            var list             = new List <IActionDescriptorProvider>()
            {
                actionDescriptorProvider,
            };

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

            var actionCollectionDescriptorProvider = new DefaultActionDescriptorsCollectionProvider(serviceContainer);
            var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionCollectionDescriptorProvider);

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

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

            return(await defaultActionSelector.SelectAsync(context));
        }
        private async Task<ActionDescriptor> InvokeActionSelector(RouteContext context)
        {
            var actionDescriptorProvider = GetActionDescriptorProvider();

            // service container does not work quite like our built in Depenency Injection container.
            var serviceContainer = new ServiceContainer();
            var list = new List<IActionDescriptorProvider>()
            {
                actionDescriptorProvider,
            };

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

            var actionCollectionDescriptorProvider = new DefaultActionDescriptorsCollectionProvider(serviceContainer);
            var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionCollectionDescriptorProvider);

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

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

            return await defaultActionSelector.SelectAsync(context);
        }