Exemple #1
0
        private ActionConstraintMatcherPolicy CreateSelector(ActionDescriptor[] actions)
        {
            // We need to actually provide some actions with some action constraints metadata
            // or else the policy will No-op.
            var actionDescriptorProvider = new Mock <IActionDescriptorProvider>();

            actionDescriptorProvider
            .Setup(a => a.OnProvidersExecuted(It.IsAny <ActionDescriptorProviderContext>()))
            .Callback <ActionDescriptorProviderContext>(c =>
            {
                for (var i = 0; i < actions.Length; i++)
                {
                    c.Results.Add(actions[i]);
                }
            });

            var actionDescriptorCollectionProvider = new DefaultActionDescriptorCollectionProvider(
                new IActionDescriptorProvider[] { actionDescriptorProvider.Object, },
                Enumerable.Empty <IActionDescriptorChangeProvider>());

            var cache = new ActionConstraintCache(actionDescriptorCollectionProvider, new[]
            {
                new DefaultActionConstraintProvider(),
            });

            return(new ActionConstraintMatcherPolicy(cache));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ODataActionSelector" /> class.
 /// </summary>
 /// <param name="actionDescriptorCollectionProvider">IActionDescriptorCollectionProvider instance from dependency injection.</param>
 /// <param name="actionConstraintProviders">ActionConstraintCache instance from dependency injection.</param>
 /// <param name="loggerFactory">ILoggerFactory instance from dependency injection.</param>
 public ODataActionSelector(
     IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
     ActionConstraintCache actionConstraintProviders,
     ILoggerFactory loggerFactory)
 {
     _innerSelector = new ActionSelector(actionDescriptorCollectionProvider, actionConstraintProviders, loggerFactory);
 }
Exemple #3
0
 public TenantActionSelector(
     IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
     ActionConstraintCache actionConstraintCache,
     ILoggerFactory loggerFactory, ITenantIdentificationStrategy tenantIdentificationStrategy) : base(actionDescriptorCollectionProvider, actionConstraintCache, loggerFactory)
 {
     _tenantIdentificationStrategy = tenantIdentificationStrategy;
 }
Exemple #4
0
 /// <summary>
 /// Creates a new <see cref="FinerGrainedActionSelector"/>, which
 /// overrides <see cref="Microsoft.AspNetCore.Mvc.Internal.ActionSelector.SelectBestActions" />.
 /// </summary>
 /// <param name="actionDescriptorCollectionProvider">
 /// The <see cref="T:Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider" />.
 /// </param>
 /// <param name="actionConstraintCache">The <see cref="T:Microsoft.AspNetCore.Mvc.Internal.ActionConstraintCache" /> that
 /// providers a set of <see cref="T:Microsoft.AspNetCore.Mvc.ActionConstraints.IActionConstraint" /> instances.</param>
 /// <param name="mvcOptions"></param>
 /// <param name="loggerFactory">The <see cref="T:Microsoft.Extensions.Logging.ILoggerFactory" />.</param>
 /// <param name="parameterBinder"></param>
 /// <param name="modelBinderFactory"></param>
 /// <param name="modelMetadataProvider"></param>
 /// <remarks>The constructor parameters are passed up to the base constructor</remarks>
 public FinerGrainedActionSelector(
     IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
     ActionConstraintCache actionConstraintCache,
     ParameterBinder parameterBinder,
     IModelBinderFactory modelBinderFactory,
     IModelMetadataProvider modelMetadataProvider,
     IOptions <MvcOptions> mvcOptions,
     ILoggerFactory loggerFactory)
 {
     if (parameterBinder == null)
     {
         throw new ArgumentNullException(nameof(parameterBinder));
     }
     if (modelBinderFactory == null)
     {
         throw new ArgumentNullException(nameof(modelBinderFactory));
     }
     if (modelMetadataProvider == null)
     {
         throw new ArgumentNullException(nameof(modelMetadataProvider));
     }
     if (mvcOptions == null)
     {
         throw new ArgumentNullException(nameof(mvcOptions));
     }
     this.actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
     this.actionConstraintCache = actionConstraintCache;
     logger = loggerFactory.CreateLogger <FinerGrainedActionSelector>();
     actionDisambiguator =
         new ActionDisambiguatorForOverloadedMethods(modelBinderFactory, modelMetadataProvider, mvcOptions.Value, parameterBinder);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ODataActionSelector" /> class.
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="actionConstraintProviders"></param>
        /// <param name="loggerFactory"></param>
#if NETSTANDARD2_0
        ///<param name="actionDescriptorCollectionProvider"></param>
        public ODataActionSelector(IServiceProvider serviceProvider,
                                   IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
                                   ActionConstraintCache actionConstraintProviders,
                                   ILoggerFactory loggerFactory)
        {
            _serviceProvider = serviceProvider;
            _selector        = new ActionSelector(actionDescriptorCollectionProvider, actionConstraintProviders, loggerFactory);
        }
Exemple #6
0
 public TestApiVersionActionSelector(
     IActionSelectorDecisionTreeProvider decisionTreeProvider,
     ActionConstraintCache actionConstraintCache,
     IOptions <ApiVersioningOptions> options,
     ILoggerFactory loggerFactory)
     : base(decisionTreeProvider, actionConstraintCache, options, loggerFactory)
 {
 }
 /// <param name="decisionTreeProvider"></param>
 public ODataActionSelector(IServiceProvider serviceProvider,
                            IActionSelectorDecisionTreeProvider decisionTreeProvider,
                            ActionConstraintCache actionConstraintProviders,
                            ILoggerFactory loggerFactory)
 {
     _serviceProvider = serviceProvider;
     _selector        = new ActionSelector(decisionTreeProvider, actionConstraintProviders, loggerFactory);
 }
 public TestApiVersionActionSelector(
     IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
     ActionConstraintCache actionConstraintCache,
     IOptions <ApiVersioningOptions> options,
     ILoggerFactory loggerFactory)
     : base(actionDescriptorCollectionProvider, actionConstraintCache, options, loggerFactory)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ODataApiVersionActionSelector"/> class.
 /// </summary>
 /// <param name="actionDescriptorCollectionProvider">The <see cref="IActionDescriptorCollectionProvider "/> used to select candidate routes.</param>
 /// <param name="actionConstraintCache">The <see cref="ActionConstraintCache"/> that providers a set of <see cref="IActionConstraint"/> instances.</param>
 /// <param name="options">The <see cref="ApiVersioningOptions">options</see> associated with the action selector.</param>
 /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
 /// <param name="routePolicy">The <see cref="IApiVersionRoutePolicy">route policy</see> applied to candidate matches.</param>
 public ODataApiVersionActionSelector(
     IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
     ActionConstraintCache actionConstraintCache,
     IOptions <ApiVersioningOptions> options,
     ILoggerFactory loggerFactory,
     IApiVersionRoutePolicy routePolicy) : base(actionDescriptorCollectionProvider, actionConstraintCache, options, loggerFactory, routePolicy)
 {
 }
Exemple #10
0
 /// <summary>
 /// Creates a new <see cref="ActionSelector"/>.
 /// </summary>
 /// <param name="decisionTreeProvider">The <see cref="IActionSelectorDecisionTreeProvider"/>.</param>
 /// <param name="actionConstraintCache">The <see cref="ActionConstraintCache"/> that
 /// providers a set of <see cref="IActionConstraint"/> instances.</param>
 /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
 public ActionSelector(
     IActionSelectorDecisionTreeProvider decisionTreeProvider,
     ActionConstraintCache actionConstraintCache,
     ILoggerFactory loggerFactory)
 {
     _decisionTreeProvider = decisionTreeProvider;
     _logger = loggerFactory.CreateLogger<ActionSelector>();
     _actionConstraintCache = actionConstraintCache;
 }
Exemple #11
0
 public ActionSelector(
     IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
     ActionConstraintCache actionConstraintCache,
     ILoggerFactory loggerFactory)
 {
     _actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
     _logger = loggerFactory.CreateLogger <ActionSelector>();
     _actionConstraintCache = actionConstraintCache;
 }
Exemple #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiVersionActionSelector"/> class.
 /// </summary>
 /// <param name="decisionTreeProvider">The <see cref="IActionSelectorDecisionTreeProvider"/> used to select candidate routes.</param>
 /// <param name="actionConstraintCache">The <see cref="ActionConstraintCache"/> that providers a set of <see cref="IActionConstraint"/> instances.</param>
 /// <param name="options">The <see cref="ApiVersioningOptions">options</see> associated with the action selector.</param>
 /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
 public ApiVersionActionSelector(
     IActionSelectorDecisionTreeProvider decisionTreeProvider,
     ActionConstraintCache actionConstraintCache,
     IOptions <ApiVersioningOptions> options,
     ILoggerFactory loggerFactory)
 {
     this.decisionTreeProvider  = decisionTreeProvider;
     this.actionConstraintCache = actionConstraintCache;
     this.options = options;
     logger       = loggerFactory.CreateLogger <ApiVersionActionSelector>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ODataActionSelector" /> class.
 /// </summary>
 /// <param name="actionDescriptorCollectionProvider">IActionDescriptorCollectionProvider instance from dependency injection.</param>
 /// <param name="actionConstraintProviders">ActionConstraintCache instance from dependency injection.</param>
 /// <param name="loggerFactory">ILoggerFactory instance from dependency injection.</param>
 /// <param name="modelBinderFactory">IModelBinderFactory instance from dependency injection</param>
 /// <param name="modelMetadataProvider">IModelMetadataProvider instance from dependency injection</param>
 public ODataActionSelector(
     IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
     ActionConstraintCache actionConstraintProviders,
     ILoggerFactory loggerFactory,
     IModelBinderFactory modelBinderFactory,
     IModelMetadataProvider modelMetadataProvider
     )
 {
     _innerSelector         = new ActionSelector(actionDescriptorCollectionProvider, actionConstraintProviders, loggerFactory);
     _modelBinderFactory    = modelBinderFactory;
     _modelMetadataProvider = modelMetadataProvider;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiVersionActionSelector"/> class.
 /// </summary>
 /// <param name="actionDescriptorCollectionProvider">The <see cref="IActionDescriptorCollectionProvider "/> used to select candidate routes.</param>
 /// <param name="actionConstraintCache">The <see cref="ActionConstraintCache"/> that providers a set of <see cref="IActionConstraint"/> instances.</param>
 /// <param name="options">The <see cref="ApiVersioningOptions">options</see> associated with the action selector.</param>
 /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
 /// <param name="routePolicy">The <see cref="IApiVersionRoutePolicy">route policy</see> applied to candidate matches.</param>
 public ApiVersionActionSelector(
     IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
     ActionConstraintCache actionConstraintCache,
     IOptions <ApiVersioningOptions> options,
     ILoggerFactory loggerFactory,
     IApiVersionRoutePolicy routePolicy)
 {
     this.actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
     this.actionConstraintCache = actionConstraintCache;
     this.options = options;
     Logger       = loggerFactory.CreateLogger(GetType());
     RoutePolicy  = routePolicy;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiVersionActionSelector"/> class.
 /// </summary>
 /// <param name="actionDescriptorCollectionProvider">The <see cref="IActionDescriptorCollectionProvider "/> used to select candidate routes.</param>
 /// <param name="actionConstraintProviders">The <see cref="IEnumerable{T}">sequence</see> of <see cref="IActionConstraintProvider">action constraint providers</see>.</param>
 /// <param name="options">The <see cref="ApiVersioningOptions">options</see> associated with the action selector.</param>
 /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
 /// <param name="routePolicy">The <see cref="IApiVersionRoutePolicy">route policy</see> applied to candidate matches.</param>
 public ApiVersionActionSelector(
     IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
     IEnumerable <IActionConstraintProvider> actionConstraintProviders,
     IOptions <ApiVersioningOptions> options,
     ILoggerFactory loggerFactory,
     IApiVersionRoutePolicy routePolicy)
 {
     this.actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
     actionConstraintCache = new ActionConstraintCache(actionDescriptorCollectionProvider, actionConstraintProviders);
     this.options          = options;
     Logger      = loggerFactory.CreateLogger(GetType());
     RoutePolicy = routePolicy;
 }
Exemple #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ApiVersionActionSelector"/> class.
        /// </summary>
        /// <param name="decisionTreeProvider">The <see cref="IActionSelectorDecisionTreeProvider"/> used to select candidate routes.</param>
        /// <param name="actionConstraintCache">The <see cref="ActionConstraintCache"/> that providers a set of <see cref="IActionConstraint"/> instances.</param>
        /// <param name="options">The <see cref="ApiVersioningOptions">options</see> associated with the action selector.</param>
        /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
        public ApiVersionActionSelector(
            IActionSelectorDecisionTreeProvider decisionTreeProvider,
            ActionConstraintCache actionConstraintCache,
            IOptions <ApiVersioningOptions> options,
            ILoggerFactory loggerFactory)
        {
            Arg.NotNull(decisionTreeProvider, nameof(decisionTreeProvider));
            Arg.NotNull(actionConstraintCache, nameof(actionConstraintCache));
            Arg.NotNull(options, nameof(options));
            Arg.NotNull(loggerFactory, nameof(loggerFactory));

            this.decisionTreeProvider  = decisionTreeProvider;
            this.actionConstraintCache = actionConstraintCache;
            this.options = options;
            Logger       = loggerFactory.CreateLogger(GetType());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApiVersionActionSelector"/> class.
        /// </summary>
        /// <param name="actionDescriptorCollectionProvider">The <see cref="IActionDescriptorCollectionProvider "/> used to select candidate routes.</param>
        /// <param name="actionConstraintCache">The <see cref="ActionConstraintCache"/> that providers a set of <see cref="IActionConstraint"/> instances.</param>
        /// <param name="options">The <see cref="ApiVersioningOptions">options</see> associated with the action selector.</param>
        /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
        /// <param name="routePolicy">The <see cref="IApiVersionRoutePolicy">route policy</see> applied to candidate matches.</param>
        public ApiVersionActionSelector(
            IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
            ActionConstraintCache actionConstraintCache,
            IOptions <ApiVersioningOptions> options,
            ILoggerFactory loggerFactory,
            IApiVersionRoutePolicy routePolicy)
        {
            Arg.NotNull(actionDescriptorCollectionProvider, nameof(actionDescriptorCollectionProvider));
            Arg.NotNull(actionConstraintCache, nameof(actionConstraintCache));
            Arg.NotNull(options, nameof(options));
            Arg.NotNull(loggerFactory, nameof(loggerFactory));
            Arg.NotNull(routePolicy, nameof(routePolicy));

            this.actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
            this.actionConstraintCache = actionConstraintCache;
            this.options = options;
            Logger       = loggerFactory.CreateLogger(GetType());
            RoutePolicy  = routePolicy;
        }
 public SyncOrAsyncActionSelector
 (
     IActionDescriptorCollectionProvider
     actionDescriptorCollectionProvider
     , ActionConstraintCache
     actionConstraintCache
     , ILoggerFactory
     loggerFactory
     , IConfiguration
     configuration
 )
 {
     _actionSelector = new ActionSelector
                       (
         actionDescriptorCollectionProvider
         , actionConstraintCache
         , loggerFactory
                       );
     _configuration = configuration;
 }
Exemple #19
0
 /// <summary>
 /// Creates a new <see cref="T:Microsoft.AspNetCore.Mvc.Internal.DefaultActionSelector" />.
 /// </summary>
 /// <param name="actionDescriptorCollectionProvider">
 /// The <see cref="T:Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider" />.
 /// </param>
 /// <param name="actionConstraintCache">The <see cref="T:Microsoft.AspNetCore.Mvc.Internal.ActionConstraintCache" /> that
 /// providers a set of <see cref="T:Microsoft.AspNetCore.Mvc.ActionConstraints.IActionConstraint" /> instances.</param>
 /// <param name="loggerFactory">The <see cref="T:Microsoft.Extensions.Logging.ILoggerFactory" />.</param>
 public DefaultActionSelector(IActionDescriptorCollectionProvider actionDescriptorCollectionProvider, ActionConstraintCache actionConstraintCache, ILoggerFactory loggerFactory)
 {
     this._actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
     this._logger = (ILogger)loggerFactory.CreateLogger <DefaultActionSelector>();
     this._actionConstraintCache = actionConstraintCache;
 }
Exemple #20
0
 public ActionConstraintMatcherPolicy(ActionConstraintCache actionConstraintCache)
 {
     _actionConstraintCache = actionConstraintCache;
 }
 public WebhookActionSelector(IActionDescriptorCollectionProvider actionDescriptorCollectionProvider, ActionConstraintCache actionConstraintCache, ILoggerFactory loggerFactory)
 {
     _defaultSelector = new ActionSelector(actionDescriptorCollectionProvider, actionConstraintCache, loggerFactory);
 }