Skip to content

Commit

Permalink
Move AddAsyncResultFilter to AspNetCore.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Dec 22, 2023
1 parent fd8c705 commit 31951db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;

namespace Lombiq.HelpfulLibraries.AspNetCore.Extensions;

public static class ServiceCollectionExtensions
{
/// <summary>
/// Configures <see cref="MvcOptions"/> to add the <typeparamref name="TFilter"/> to the list of filters.
/// </summary>
public static void AddAsyncResultFilter<TFilter>(this IServiceCollection services)
where TFilter : IAsyncResultFilter =>
services.Configure<MvcOptions>(options => options.Filters.Add(typeof(TFilter)));
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,4 @@ public static void AddOrchardServices(this IServiceCollection services)
services.AddLazyInjectionSupport();
services.TryAddTransient(typeof(IOrchardServices<>), typeof(OrchardServices<>));
}

/// <summary>
/// Configures <see cref="MvcOptions"/> to add the <typeparamref name="TFilter"/> to the list of filters.
/// </summary>
public static void AddAsyncResultFilter<TFilter>(this IServiceCollection services)
where TFilter : IAsyncResultFilter =>
services.Configure<MvcOptions>(options => options.Filters.Add(typeof(TFilter)));
}

0 comments on commit 31951db

Please sign in to comment.