Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 849e2b4

Browse files
Allowing the User to be constructed without a CacheContainer
1 parent 4bfcee1 commit 849e2b4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/GitHub.Api/Git/Repository.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,12 @@ public class User : IUser
423423

424424
public User(ICacheContainer cacheContainer)
425425
{
426-
this.cacheContainer = cacheContainer;
427-
cacheContainer.CacheInvalidated += (type) => { if (type == CacheType.GitUser) GitUserCacheOnCacheInvalidated(); };
428-
cacheContainer.CacheUpdated += (type, dt) => { if (type == CacheType.GitUser) CacheHasBeenUpdated(dt); };
426+
if (cacheContainer != null)
427+
{
428+
this.cacheContainer = cacheContainer;
429+
cacheContainer.CacheInvalidated += (type) => { if (type == CacheType.GitUser) GitUserCacheOnCacheInvalidated(); };
430+
cacheContainer.CacheUpdated += (type, dt) => { if (type == CacheType.GitUser) CacheHasBeenUpdated(dt); };
431+
}
429432
}
430433

431434
public void CheckAndRaiseEventsIfCacheNewer(CacheType cacheType, CacheUpdateEvent cacheUpdateEvent) => cacheContainer.CheckAndRaiseEventsIfCacheNewer(CacheType.GitUser, cacheUpdateEvent);

0 commit comments

Comments
 (0)