Пример #1
0
        /// <summary>
        /// Determines whether the action should be considered.
        /// </summary>
        /// <param name="actionRouteParameterValue">The action route parameter value.</param>
        /// <param name="actionDescriptor">The associated <see cref="HttpActionDescriptor">action descriptor</see>.</param>
        /// <param name="route">The associated <see cref="IHttpRoute">route</see>.</param>
        /// <param name="apiVersion">The <see cref="ApiVersion">API version</see> to consider the controller for.</param>
        /// <returns>True if the action should be explored; otherwise, false.</returns>
        protected override bool ShouldExploreAction(string actionRouteParameterValue, HttpActionDescriptor actionDescriptor, IHttpRoute route, ApiVersion apiVersion)
        {
            Arg.NotNull(actionDescriptor, nameof(actionDescriptor));
            Arg.NotNull(route, nameof(route));
            Arg.NotNull(apiVersion, nameof(apiVersion));

            if (!(route is ODataRoute))
            {
                return(base.ShouldExploreAction(actionRouteParameterValue, actionDescriptor, route, apiVersion));
            }

            if (Options.UseApiExplorerSettings)
            {
                var setting = actionDescriptor.GetCustomAttributes <ApiExplorerSettingsAttribute>().FirstOrDefault();

                if (setting?.IgnoreApi == true)
                {
                    return(false);
                }
            }

            return(actionDescriptor.IsMappedTo(apiVersion));
        }
 /// <summary>
 /// Returns a value indicating whether the specified action should be mapped using attribute routing conventions.
 /// </summary>
 /// <param name="action">The <see cref="HttpActionDescriptor">action descriptor</see> to evaluate.</param>
 /// <param name="apiVersion">The <see cref="ApiVersion">API version</see> to evaluate.</param>
 /// <returns>True if the <paramref name="action"/> should be mapped as an OData action or function; otherwise, false.</returns>
 /// <remarks>This method will match any OData action that explicitly or implicitly matches the API version applied
 /// to the associated <see cref="ApiVersionModel">model</see>.</remarks>
 public virtual bool ShouldMapAction(HttpActionDescriptor action, ApiVersion?apiVersion) => action.IsMappedTo(apiVersion);
Пример #3
0
 /// <summary>
 /// Returns a value indicating whether the specified action should be mapped using attribute routing conventions.
 /// </summary>
 /// <param name="action">The <see cref="HttpActionDescriptor">action descriptor</see> to evaluate.</param>
 /// <returns>True if the <paramref name="action"/> should be mapped as an OData action or function; otherwise, false.</returns>
 /// <remarks>This method will match any OData action that explicitly or implicitly matches matches the API version applied
 /// to the associated <see cref="ApiVersionModel">model</see>.</remarks>
 public virtual bool ShouldMapAction(HttpActionDescriptor action)
 {
     Arg.NotNull(action, nameof(action));
     return(action.IsMappedTo(ApiVersion));
 }