Example #1
0
            public string GetViewLocation(HttpContextBase httpContext, string key)
            {
                var    d = GetRequestCache(httpContext);
                string location;

                if (!d.TryGetValue(key, out location))
                {
                    location = _cache.GetViewLocation(httpContext, key);
                    d[key]   = location;
                }
                return(location);
            }
Example #2
0
        public string GetViewLocation(HttpContextBase httpContext, string key)
        {
            var    firstLevelCache = getRequestCache(httpContext);
            string location;

            if (!firstLevelCache.TryGetValue(key, out location))
            {
                location             = _secondLevelCache.GetViewLocation(httpContext, key);
                firstLevelCache[key] = location;
            }
            return(location);
        }
Example #3
0
        private string GetVirtualPath(ControllerContext controllerContext, string name, IEnumerable <string> extensions, string cacheKeyPrefix, bool useCache, out IEnumerable <string> searchedLocations)
        {
            //设置输出参数的默认值
            searchedLocations = _emptyLocations;

            //如果没有指定查找的名称则返回空(该调用方式在无母版页的视图中出现)
            if (string.IsNullOrWhiteSpace(name))
            {
                return(string.Empty);
            }

            string controllerName     = controllerContext.RouteData.GetRequiredString("controller");
            bool   nameRepresentsPath = IsSpecificPath(name);
            string cacheKey           = CreateCacheKey(cacheKeyPrefix, name, (nameRepresentsPath) ? string.Empty : controllerName);

            if (useCache)
            {
                return(_viewLocationCache.GetViewLocation(controllerContext.HttpContext, cacheKey));
            }

            object nodePath;

            //从路由数据中获取由ControllerFactory解析出的当前Controller对应的插件路径
            if (!controllerContext.RouteData.DataTokens.TryGetValue("controller.path", out nodePath))
            {
                return(string.Empty);
            }

            //查找当前控制器位于插件树中的节点
            var node = _pluginContext.PluginTree.Find((string)nodePath);

            //获取当前插件对应的视图位置
            IEnumerable <string> locations = this.GetSearchLocations((node == null ? null : node.Plugin), controllerName, name, extensions);

            foreach (string location in locations)
            {
                if (this.FileExists(controllerContext, location))
                {
                    _viewLocationCache.InsertViewLocation(controllerContext.HttpContext, cacheKey, location);
                    return(location);
                }
            }

            //设置输出参数为所有搜索的路径
            searchedLocations = locations.ToArray();

            return(string.Empty);
        }
Example #4
0
 public string GetViewLocation(HttpContextBase httpContext, string key)
 {
     key = _assemblyName + "::" + key;
     return(_innerCache.GetViewLocation(httpContext, key));
 }
 string IViewLocationCache.GetViewLocation(System.Web.HttpContextBase httpContext, string key)
 {
     return(inner.GetViewLocation(httpContext, httpContext.GetTheme() + key));
 }