Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HttpRequestCachePolicy.cs
Go to the documentation of this file.
2
3namespace System.Net.Cache;
4
6{
8
9 private readonly TimeSpan _maxAge = TimeSpan.MaxValue;
10
11 private readonly TimeSpan _minFresh = TimeSpan.MinValue;
12
13 private readonly TimeSpan _maxStale = TimeSpan.MinValue;
14
15 public new HttpRequestCacheLevel Level { get; }
16
18 {
19 get
20 {
22 {
24 }
25 return _lastSyncDateUtc;
26 }
27 }
28
30
32
34
39
41 : base(MapLevel(level))
42 {
43 Level = level;
44 }
45
46 public HttpRequestCachePolicy(HttpCacheAgeControl cacheAgeControl, TimeSpan ageOrFreshOrStale)
48 {
49 switch (cacheAgeControl)
50 {
51 case HttpCacheAgeControl.MinFresh:
52 _minFresh = ageOrFreshOrStale;
53 break;
54 case HttpCacheAgeControl.MaxAge:
55 _maxAge = ageOrFreshOrStale;
56 break;
57 case HttpCacheAgeControl.MaxStale:
58 _maxStale = ageOrFreshOrStale;
59 break;
60 default:
61 throw new ArgumentException(System.SR.Format(System.SR.net_invalid_enum, "HttpCacheAgeControl"), "cacheAgeControl");
62 }
63 }
64
65 public HttpRequestCachePolicy(HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale)
67 {
68 switch (cacheAgeControl)
69 {
70 case HttpCacheAgeControl.MinFresh:
71 _minFresh = freshOrStale;
72 break;
73 case HttpCacheAgeControl.MaxAge:
74 _maxAge = maxAge;
75 break;
76 case HttpCacheAgeControl.MaxStale:
77 _maxStale = freshOrStale;
78 break;
79 case HttpCacheAgeControl.MaxAgeAndMinFresh:
80 _maxAge = maxAge;
81 _minFresh = freshOrStale;
82 break;
83 case HttpCacheAgeControl.MaxAgeAndMaxStale:
84 _maxAge = maxAge;
85 _maxStale = freshOrStale;
86 break;
87 default:
88 throw new ArgumentException(System.SR.Format(System.SR.net_invalid_enum, "HttpCacheAgeControl"), "cacheAgeControl");
89 }
90 }
91
92 public HttpRequestCachePolicy(DateTime cacheSyncDate)
94 {
95 _lastSyncDateUtc = cacheSyncDate.ToUniversalTime();
96 }
97
98 public HttpRequestCachePolicy(HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale, DateTime cacheSyncDate)
99 : this(cacheAgeControl, maxAge, freshOrStale)
100 {
101 _lastSyncDateUtc = cacheSyncDate.ToUniversalTime();
102 }
103
104 public override string ToString()
105 {
106 return "Level:" + Level.ToString() + ((_maxAge == TimeSpan.MaxValue) ? string.Empty : (" MaxAge:" + _maxAge)) + ((_minFresh == TimeSpan.MinValue) ? string.Empty : (" MinFresh:" + _minFresh)) + ((_maxStale == TimeSpan.MinValue) ? string.Empty : (" MaxStale:" + _maxStale)) + ((CacheSyncDate == DateTime.MinValue) ? string.Empty : (" CacheSyncDate:" + CacheSyncDate.ToString(CultureInfo.CurrentCulture)));
107 }
108
110 {
111 if (level <= HttpRequestCacheLevel.NoCacheNoStore)
112 {
113 return (RequestCacheLevel)level;
114 }
115 return level switch
116 {
117 HttpRequestCacheLevel.CacheOrNextCacheOnly => RequestCacheLevel.CacheOnly,
118 HttpRequestCacheLevel.Refresh => RequestCacheLevel.Reload,
119 _ => throw new ArgumentOutOfRangeException("level"),
120 };
121 }
122}
static CultureInfo CurrentCulture
HttpRequestCachePolicy(HttpRequestCacheLevel level)
HttpRequestCachePolicy(HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale)
HttpRequestCachePolicy(HttpCacheAgeControl cacheAgeControl, TimeSpan ageOrFreshOrStale)
static RequestCacheLevel MapLevel(HttpRequestCacheLevel level)
HttpRequestCachePolicy(HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale, DateTime cacheSyncDate)
static string net_invalid_enum
Definition SR.cs:40
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7
static readonly DateTime MaxValue
Definition DateTime.cs:37
static readonly DateTime MinValue
Definition DateTime.cs:35
DateTime ToUniversalTime()
Definition DateTime.cs:1134
DateTime ToLocalTime()
Definition DateTime.cs:1068
override string ToString()
Definition DateTime.cs:1109
static readonly TimeSpan MinValue
Definition TimeSpan.cs:25
static readonly TimeSpan MaxValue
Definition TimeSpan.cs:23