Beispiel #1
0
        private async Task <ActionDescriptor> InvokeActionSelector(
            RouteContext context,
            IActionDiscoveryConventions actionDiscoveryConventions = null)
        {
            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 bindingProvider = new Mock <IActionBindingContextProvider>();

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

            return(await defaultActionSelector.SelectAsync(context));
        }
 public ControllerActionDescriptorProvider(IAssemblyProvider assemblyProvider,
                                           IActionDiscoveryConventions conventions,
                                           IGlobalFilterProvider globalFilters,
                                           IOptions <MvcOptions> optionsAccessor)
 {
     _assemblyProvider = assemblyProvider;
     _conventions      = conventions;
     _globalFilters    = globalFilters.Filters;
     _modelConventions = optionsAccessor.Options.ApplicationModelConventions;
 }
 public ReflectedActionDescriptorProvider(IControllerAssemblyProvider controllerAssemblyProvider,
                                          IActionDiscoveryConventions conventions,
                                          IEnumerable<IFilter> globalFilters,
                                          IOptionsAccessor<MvcOptions> optionsAccessor,
                                          IInlineConstraintResolver constraintResolver)
 {
     _controllerAssemblyProvider = controllerAssemblyProvider;
     _conventions = conventions;
     _globalFilters = globalFilters ?? Enumerable.Empty<IFilter>();
     _modelConventions = optionsAccessor.Options.ApplicationModelConventions;
     _constraintResolver = constraintResolver;
 }
 public ReflectedActionDescriptorProvider(IControllerAssemblyProvider controllerAssemblyProvider,
                                          IActionDiscoveryConventions conventions,
                                          IEnumerable <IFilter> globalFilters,
                                          IOptionsAccessor <MvcOptions> optionsAccessor,
                                          IInlineConstraintResolver constraintResolver)
 {
     _controllerAssemblyProvider = controllerAssemblyProvider;
     _conventions        = conventions;
     _globalFilters      = globalFilters ?? Enumerable.Empty <IFilter>();
     _modelConventions   = optionsAccessor.Options.ApplicationModelConventions;
     _constraintResolver = constraintResolver;
 }
Beispiel #5
0
        private ControllerActionDescriptorProvider GetActionDescriptorProvider(
            IActionDiscoveryConventions actionDiscoveryConventions = null)
        {
            var assemblyProvider = new StaticAssemblyProvider();

            if (actionDiscoveryConventions == null)
            {
                var controllerTypes = typeof(ActionAttributeTests)
                                      .GetNestedTypes(BindingFlags.NonPublic)
                                      .Select(t => t.GetTypeInfo());

                actionDiscoveryConventions = new StaticActionDiscoveryConventions(controllerTypes.ToArray());
            }

            return(new ControllerActionDescriptorProvider(
                       assemblyProvider,
                       actionDiscoveryConventions,
                       new TestGlobalFilterProvider(),
                       new MockMvcOptionsAccessor()));
        }
Beispiel #6
0
        private ReflectedActionDescriptorProvider GetActionDescriptorProvider(
            IActionDiscoveryConventions actionDiscoveryConventions = null)
        {
            var controllerAssemblyProvider = new StaticControllerAssemblyProvider();

            if (actionDiscoveryConventions == null)
            {
                var controllerTypes = typeof(ActionAttributeTests)
                                      .GetNestedTypes(BindingFlags.NonPublic)
                                      .Select(t => t.GetTypeInfo());

                actionDiscoveryConventions = new StaticActionDiscoveryConventions(controllerTypes.ToArray());
            }

            return(new ReflectedActionDescriptorProvider(
                       controllerAssemblyProvider,
                       actionDiscoveryConventions,
                       null,
                       new MockMvcOptionsAccessor(),
                       Mock.Of <IInlineConstraintResolver>()));
        }
Beispiel #7
0
        private ReflectedActionDescriptorProvider GetActionDescriptorProvider(
            IActionDiscoveryConventions actionDiscoveryConventions  = null)
        {
            var controllerAssemblyProvider = new StaticControllerAssemblyProvider();

            if (actionDiscoveryConventions == null)
            {
                var controllerTypes = typeof(ActionAttributeTests)
                    .GetNestedTypes(BindingFlags.NonPublic)
                    .Select(t => t.GetTypeInfo());

                actionDiscoveryConventions = new StaticActionDiscoveryConventions(controllerTypes.ToArray());
            }

            return new ReflectedActionDescriptorProvider(
                                        controllerAssemblyProvider,
                                        actionDiscoveryConventions,
                                        null,
                                        new MockMvcOptionsAccessor(),
                                        Mock.Of<IInlineConstraintResolver>());
        }
Beispiel #8
0
        private async Task<ActionDescriptor> InvokeActionSelector(
            RouteContext context,
            IActionDiscoveryConventions actionDiscoveryConventions = null)
        {
            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);
        }