示例#1
0
 internal static IEntryLink CreateLinkingScope()
 {
     var parentLink = ContextLink;
     var newLink = new EntryLink(parent: parentLink);
     ContextLink = newLink;
     return newLink;
 }
示例#2
0
        internal static void DisposeLinkingScope()
        {
            var currentLink = ContextLink;
            var priorLink   = ((EntryLink)currentLink).Parent;

            ContextLink = priorLink;
        }
示例#3
0
        internal static IEntryLink CreateLinkingScope()
        {
            var parentLink = ContextLink;
            var newLink    = new EntryLink(parent: parentLink);

            ContextLink = newLink;
            return(newLink);
        }
示例#4
0
        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());
        }
示例#5
0
        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);
        }
示例#6
0
 public EntryLink(EntryLink parent)
 {
     Parent = parent;
 }
示例#7
0
        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);
        }
示例#8
0
 public EntryLink(EntryLink parent)
 {
     Parent = parent;
 }
示例#9
0
 internal static void DisposeLinkingScope()
 {
     var currentLink = ContextLink;
     var priorLink = ((EntryLink)currentLink).Parent;
     ContextLink = priorLink;
 }