CacheableAsyncResultFilterExtensions Class
Definition
- Namespace
- Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable
- Assemblies
- Cuemon.Extensions.AspNetCore.Mvc.dll
Extension methods for the ICacheableAsyncResultFilter interface.
public static class CacheableAsyncResultFilterExtensions
- Inheritance
-
objectCacheableAsyncResultFilterExtensions
Examples
The following example configures the same cache-filter collection patterns exercised by the unit tests: use the convenience methods for the default pipeline, or switch to the generic overloads when you need explicit ordering and option control.
using System;
using Cuemon.AspNetCore.Mvc.Filters.Cacheable;
using Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable;
namespace Cuemon.Extensions.AspNetCore.Mvc.Filters.Cacheable.DocExamples;
public sealed class CacheableAsyncResultFilterExtensionsExample
{
public HttpCacheableOptions CreateDefaultProfile()
{
var options = new HttpCacheableOptions();
options.Filters.AddLastModifiedHeader();
options.Filters.AddEntityTagHeader();
return options;
}
public HttpCacheableOptions CreateCustomProfile()
{
var options = new HttpCacheableOptions();
options.Filters.AddFilter<HttpEntityTagHeaderFilter, HttpEntityTagHeaderOptions>(entityTag =>
{
entityTag.UseEntityTagResponseParser = true;
});
options.Filters.InsertFilter<HttpLastModifiedHeaderFilter>(0);
return options;
}
public void Describe()
{
var defaultProfile = CreateDefaultProfile();
var customProfile = CreateCustomProfile();
Console.WriteLine($"{defaultProfile.Filters.Count} default filters, {customProfile.Filters.Count} custom filters.");
}
}
Methods
| Name | Description |
|---|---|
| AddEntityTagHeader(IList<ICacheableAsyncResultFilter>, Action<HttpEntityTagHeaderOptions>) | Adds an HttpEntityTagHeaderFilter filter to the list. |
| AddFilter<T>(IList<ICacheableAsyncResultFilter>) | Adds a cache related HTTP filter to the list. |
| AddFilter<T, TOptions>(IList<ICacheableAsyncResultFilter>, Action<TOptions>) | Adds a cache related HTTP filter to the list. |
| AddLastModifiedHeader(IList<ICacheableAsyncResultFilter>, Action<HttpLastModifiedHeaderOptions>) | Adds an HttpLastModifiedHeaderFilter filter to the list. |
| InsertFilter<T>(IList<ICacheableAsyncResultFilter>, int) | Inserts a cache related HTTP filter to the list at the specified |
| InsertFilter<T, TOptions>(IList<ICacheableAsyncResultFilter>, int, Action<TOptions>) | Inserts a cache related HTTP filter to the list at the specified |