Skip to content

Commit d4822df

Browse files
authored
Merge pull request #9 from Leefrost/internal-access-only
Change visibility for extensions
2 parents 376add3 + b28dea3 commit d4822df

File tree

7 files changed

+15
-18
lines changed

7 files changed

+15
-18
lines changed

samples/ConsoleApp/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{
2121
for (int i = 1; i <= 5; ++i)
2222
{
23-
Console.Write($"Try: {i}: {url} ");
23+
Console.Write($"Attempt: {i}: {url} ");
2424

2525
var stopwatch = Stopwatch.StartNew();
2626
var result = await httpClient.GetAsync(url);

src/HttpClient.Cache/CacheDataExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
namespace HttpClient.Cache;
55

6-
public static class CacheDataExtensions
6+
internal static class CacheDataExtensions
77
{
8-
public static byte[] Pack(this CacheData cacheData)
8+
internal static byte[] Pack(this CacheData cacheData)
99
{
1010
var json = JsonConvert.SerializeObject(cacheData);
1111
var bytes = new byte[json.Length * sizeof(char)];
@@ -14,7 +14,7 @@ public static byte[] Pack(this CacheData cacheData)
1414
return bytes;
1515
}
1616

17-
public static CacheData? Unpack(this byte[] cacheData)
17+
internal static CacheData? Unpack(this byte[] cacheData)
1818
{
1919
try
2020
{

src/HttpClient.Cache/CacheEntryExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace HttpClient.Cache;
22

3-
public static class CacheEntryExtensions
3+
internal static class CacheEntryExtensions
44
{
5-
public static ICacheEntry AddExpirationToken(this ICacheEntry entry, IChangeToken token)
5+
internal static ICacheEntry AddExpirationToken(this ICacheEntry entry, IChangeToken token)
66
{
77
if (token == null)
88
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace HttpClient.Cache.InMemory.Clock;
22

3-
public class SystemClock: ISystemClock
3+
internal class SystemClock: ISystemClock
44
{
55
public DateTimeOffset UtcNow => DateTimeOffset.UtcNow;
66
}

src/HttpClient.Cache/InMemory/MemoryCacheExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace HttpClient.Cache.InMemory;
44

5-
public static class MemoryCacheExtensions
5+
internal static class MemoryCacheExtensions
66
{
77
public static Task<bool> TryGetAsync(this IMemoryCache cache, string key, out CacheData? cacheData)
88
{

src/HttpClient.Cache/InMemory/MemoryCacheOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace HttpClient.Cache.InMemory;
44

55
public class MemoryCacheOptions
66
{
7-
public TimeSpan ExpirationScanFrequency { get; } = TimeSpan.FromMinutes(1.0);
8-
9-
public ISystemClock? Clock { get; set; }
7+
public TimeSpan ExpirationScanFrequency { get; set; } = TimeSpan.FromSeconds(1.0);
8+
9+
public ISystemClock Clock { get; set; } = new SystemClock();
1010
}

src/HttpClient.Cache/Utils/HttpStatusCodeExtensions.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace HttpClient.Cache.Utils;
44

5-
public static class HttpStatusCodeExtensions
5+
internal static class HttpStatusCodeExtensions
66
{
77
public static TimeSpan GetAbsoluteExpirationRelativeToNow(this HttpStatusCode statusCode,
88
IDictionary<HttpStatusCode, TimeSpan> mapping)
@@ -13,11 +13,8 @@ public static TimeSpan GetAbsoluteExpirationRelativeToNow(this HttpStatusCode st
1313
}
1414

1515
var code = (int)statusCode;
16-
if (mapping.TryGetValue((HttpStatusCode)(Math.Floor(code / 100.0) * 100), out expiration))
17-
{
18-
return expiration;
19-
}
20-
21-
return TimeSpan.FromDays(1);
16+
return mapping.TryGetValue((HttpStatusCode)(Math.Floor(code / 100.0) * 100), out expiration)
17+
? expiration
18+
: TimeSpan.FromDays(1);
2219
}
2320
}

0 commit comments

Comments
 (0)