示例#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,
                                                                   DefaultActionDiscoveryConventions actionDiscoveryConventions)
        {
            var actionDescriptorProvider = GetActionDescriptorProvider(actionDiscoveryConventions);
            var descriptorProvider       =
                new NestedProviderManager <ActionDescriptorProviderContext>(new[] { actionDescriptorProvider });

            var serviceContainer = new ServiceContainer();

            serviceContainer.AddService(typeof(INestedProviderManager <ActionDescriptorProviderContext>),
                                        descriptorProvider);

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

            var actionConstraintProvider = new NestedProviderManager <ActionConstraintProviderContext>(
                new INestedProvider <ActionConstraintProviderContext>[]
            {
                new DefaultActionConstraintProvider(serviceContainer),
            });

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

            return(await defaultActionSelector.SelectAsync(context));
        }
        private async Task <ActionDescriptor> InvokeActionSelector(RouteContext context,
                                                                   DefaultActionDiscoveryConventions actionDiscoveryConventions)
        {
            var actionDescriptorProvider = GetActionDescriptorProvider(actionDiscoveryConventions);
            var descriptorProvider       =
                new NestedProviderManager <ActionDescriptorProviderContext>(new[] { actionDescriptorProvider });

            var serviceContainer = new ServiceContainer();

            serviceContainer.AddService(typeof(INestedProviderManager <ActionDescriptorProviderContext>),
                                        descriptorProvider);

            var actionCollectionDescriptorProvider = new DefaultActionDescriptorsCollectionProvider(serviceContainer);

            var bindingProvider = new Mock <IActionBindingContextProvider>();

            var defaultActionSelector = new DefaultActionSelector(actionCollectionDescriptorProvider,
                                                                  bindingProvider.Object,
                                                                  NullLoggerFactory.Instance);

            return(await defaultActionSelector.SelectAsync(context));
        }
        private async Task<ActionDescriptor> InvokeActionSelector(RouteContext context,
                                                                  DefaultActionDiscoveryConventions actionDiscoveryConventions)
        {
            var actionDescriptorProvider = GetActionDescriptorProvider(actionDiscoveryConventions);
            var descriptorProvider =
                new NestedProviderManager<ActionDescriptorProviderContext>(new[] { actionDescriptorProvider });

            var serviceContainer = new ServiceContainer();
            serviceContainer.AddService(typeof(INestedProviderManager<ActionDescriptorProviderContext>),
                                        descriptorProvider);

            var actionCollectionDescriptorProvider = new DefaultActionDescriptorsCollectionProvider(serviceContainer);

            var bindingProvider = new Mock<IActionBindingContextProvider>();

            var defaultActionSelector = new DefaultActionSelector(actionCollectionDescriptorProvider,
                                                                  bindingProvider.Object,
                                                                  NullLoggerFactory.Instance);

            return await defaultActionSelector.SelectAsync(context);
        }