internal static IEntryLink CreateLinkingScope() { var parentLink = ContextLink; var newLink = new EntryLink(parent: parentLink); ContextLink = newLink; return newLink; }
internal static void DisposeLinkingScope() { var currentLink = ContextLink; var priorLink = ((EntryLink)currentLink).Parent; ContextLink = priorLink; }
internal static IEntryLink CreateLinkingScope() { var parentLink = ContextLink; var newLink = new EntryLink(parent: parentLink); ContextLink = newLink; return(newLink); }
public void UpdateCacheEntryOptions_CopiesTriggersFromEntryLink() { // Arrange var expiresSliding = TimeSpan.FromSeconds(30); var expected = new[] { Mock.Of<IChangeToken>(), Mock.Of<IChangeToken>() }; var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache, new HtmlTestEncoder()) { ExpiresSliding = expiresSliding }; var entryLink = new EntryLink(); entryLink.AddExpirationTokens(expected); // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink); // Assert Assert.Equal(expected, cacheEntryOptions.ExpirationTokens.ToArray()); }
public void UpdateCacheEntryOptions_PrefersAbsoluteExpirationSpecifiedOnEntryLinkOverExpiresOn() { // Arrange var expiresOn1 = DateTimeOffset.UtcNow.AddDays(12); var expiresOn2 = DateTimeOffset.UtcNow.AddMinutes(4); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache, new HtmlTestEncoder()) { ExpiresOn = expiresOn1 }; var entryLink = new EntryLink(); entryLink.SetAbsoluteExpiration(expiresOn2); // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink); // Assert Assert.Equal(expiresOn2, cacheEntryOptions.AbsoluteExpiration); }
public EntryLink(EntryLink parent) { Parent = parent; }
public void UpdateCacheEntryOptions_UsesAbsoluteExpirationSpecifiedOnEntryLink() { // Arrange var expiresOn = DateTimeOffset.UtcNow.AddMinutes(7); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { }; var entryLink = new EntryLink(); entryLink.SetAbsoluteExpiration(expiresOn); // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink); // Assert Assert.Equal(expiresOn, cacheEntryOptions.AbsoluteExpiration); }