private ModuleViewLocationCacheResult LocatePageFromPath(string executingFilePath, string pagePath) { var applicationRelativePath = GetAbsolutePath(executingFilePath, pagePath); var cacheKey = new ModuleViewLocationCacheKey(applicationRelativePath, null); if (!ViewLookupCache.TryGetValue(cacheKey, out ModuleViewLocationCacheResult cacheResult)) { var expirationTokens = new HashSet <IChangeToken>(); cacheResult = CreateCacheResult(expirationTokens, applicationRelativePath); var cacheEntryOptions = new MemoryCacheEntryOptions(); cacheEntryOptions.SetSlidingExpiration(_cacheExpirationDuration); foreach (var expirationToken in expirationTokens) { cacheEntryOptions.AddExpirationToken(expirationToken); } // No views were found at the specified location. Create a not found result. if (cacheResult == null) { cacheResult = new ModuleViewLocationCacheResult(new[] { applicationRelativePath }); } cacheResult = ViewLookupCache.Set( cacheKey, cacheResult, cacheEntryOptions); } return(cacheResult); }
private ModuleViewLocationCacheResult LocatePageFromViewLocations( ActionContext actionContext, string moduleViewName) { var expanderContext = new ViewLocationExpanderContext( actionContext, moduleViewName, null, null, null, false); Dictionary <string, string> expanderValues = null; var expanders = _options.ModuleViewLocationExpanders; var expandersCount = expanders.Count; if (expandersCount > 0) { expanderValues = new Dictionary <string, string>(StringComparer.Ordinal); expanderContext.Values = expanderValues; for (var i = 0; i < expandersCount; i++) { expanders[i].PopulateValues(expanderContext); } } var cacheKey = new ModuleViewLocationCacheKey( expanderContext.ViewName, expanderValues); if (!ViewLookupCache.TryGetValue(cacheKey, out ModuleViewLocationCacheResult cacheResult)) { cacheResult = OnCacheMiss(expanderContext, cacheKey); } return(cacheResult); }