-
Notifications
You must be signed in to change notification settings - Fork 3
/
HttpLastModifiedHeaderOptions.cs
58 lines (55 loc) · 2.52 KB
/
HttpLastModifiedHeaderOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using Cuemon.AspNetCore.Http;
using Cuemon.Configuration;
using Cuemon.Data.Integrity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Cuemon.AspNetCore.Mvc.Filters.Cacheable
{
/// <summary>
/// Specifies options that is related to the <see cref="HttpLastModifiedHeaderFilter" />.
/// </summary>
/// <seealso cref="HttpCacheableFilter"/>
public class HttpLastModifiedHeaderOptions : IParameterObject
{
/// <summary>
/// Initializes a new instance of the <see cref="HttpLastModifiedHeaderOptions"/> class.
/// </summary>
/// <remarks>
/// The following table shows the initial property values for an instance of <see cref="HttpEntityTagHeaderOptions"/>.
/// <list type="table">
/// <listheader>
/// <term>Property</term>
/// <description>Initial Value</description>
/// </listheader>
/// <item>
/// <term><see cref="LastModifiedProvider"/></term>
/// <description><code>
/// (timestamp, context) =>
/// {
/// Decorator.Enclose(context.Response).TryAddOrUpdateLastModifiedHeader(context.Request, timestamp.Modified ?? timestamp.Created);
/// };
/// </code></description>
/// </item>
/// </list>
/// </remarks>
public HttpLastModifiedHeaderOptions()
{
LastModifiedProvider = (timestamp, context) =>
{
Decorator.Enclose(context.Response).AddOrUpdateLastModifiedHeader(context.Request, timestamp.Modified ?? timestamp.Created);
};
}
/// <summary>
/// Gets a value indicating whether this instance has an <see cref="LastModifiedProvider"/>.
/// </summary>
/// <value><c>true</c> if this instance has an <see cref="LastModifiedProvider"/>; otherwise, <c>false</c>.</value>
public bool HasLastModifiedProvider => LastModifiedProvider != null;
/// <summary>
/// Gets or sets the delegate that is invoked when a result of a <see cref="ResultExecutingContext"/> is an <see cref="ObjectResult"/> and the value is an <see cref="IEntityDataTimestamp"/> implementation.
/// </summary>
/// <value>The delegate that provides an HTTP Last-Modified header.</value>
public Action<IEntityDataTimestamp, HttpContext> LastModifiedProvider { get; set; }
}
}