/// <summary>
        /// Adds or replaces the configured <see cref="IApiExplorer">API explorer</see> with an implementation that supports OData and API versioning.
        /// </summary>
        /// <param name="configuration">The <see cref="HttpConfiguration">configuration</see> used to add the API explorer.</param>
        /// <param name="useApiExplorerSettings">Indicates whether the <see cref="ODataApiExplorer">OData API explorer</see> will use the
        /// <see cref="ApiExplorerSettingsAttribute"/> when present.</param>
        /// <returns>The newly registered <see cref="ODataApiExplorer">versioned API explorer</see>.</returns>
        /// <remarks>This method always replaces the <see cref="IApiExplorer"/> with a new instance of <see cref="ODataApiExplorer"/>.</remarks>
        public static ODataApiExplorer AddODataApiExplorer(this HttpConfiguration configuration, bool useApiExplorerSettings)
        {
            Arg.NotNull(configuration, nameof(configuration));
            Contract.Ensures(Contract.Result <ODataApiExplorer>() != null);

            var apiExplorer = new ODataApiExplorer(configuration)
            {
                UseApiExplorerSettings = useApiExplorerSettings
            };

            configuration.Services.Replace(typeof(IApiExplorer), apiExplorer);
            return(apiExplorer);
        }
示例#2
0
        /// <summary>
        /// Adds or replaces the configured <see cref="IApiExplorer">API explorer</see> with an implementation that supports OData and API versioning.
        /// </summary>
        /// <param name="configuration">The <see cref="HttpConfiguration">configuration</see> used to add the API explorer.</param>
        /// <param name="setupAction">An <see cref="Action{T}">action</see> used to configure the provided options.</param>
        /// <returns>The newly registered <see cref="ODataApiExplorer">versioned API explorer</see>.</returns>
        /// <remarks>This method always replaces the <see cref="IApiExplorer"/> with a new instance of <see cref="ODataApiExplorer"/>.</remarks>
        public static ODataApiExplorer AddODataApiExplorer(this HttpConfiguration configuration, Action <ODataApiExplorerOptions> setupAction)
        {
            Arg.NotNull(configuration, nameof(configuration));
            Arg.NotNull(setupAction, nameof(setupAction));
            Contract.Ensures(Contract.Result <ODataApiExplorer>() != null);

            var options = new ODataApiExplorerOptions(configuration);

            setupAction(options);

            var apiExplorer = new ODataApiExplorer(configuration, options);

            configuration.Services.Replace(typeof(IApiExplorer), apiExplorer);
            return(apiExplorer);
        }