internal DisplayInfo GetDisplayInfoForVirtualPath( string virtualPath, HttpContextBase httpContext, Func <string, bool> virtualPathExists, IDisplayMode currentDisplayMode, bool requireConsistentDisplayMode ) { // Performance sensitive int first = FindFirstAvailableDisplayMode( currentDisplayMode, requireConsistentDisplayMode ); for (int i = first; i < _displayModes.Count; i++) { IDisplayMode mode = _displayModes[i]; if (mode.CanHandleContext(httpContext)) { DisplayInfo info = mode.GetDisplayInfo( httpContext, virtualPath, virtualPathExists ); if (info != null) { return(info); } } } return(null); }
private bool TryResolveView(HttpContextBase httpContext, IDisplayMode displayMode, ref string path, ICollection <string> viewLocationsSearched) { path = NormalizeViewName(VirtualPathUtility.ToAppRelative(path)); // resolve relative path portions var displayInfo = displayMode.GetDisplayInfo(httpContext, path, _views.ContainsKey); if (displayInfo == null || displayInfo.FilePath == null) { viewLocationsSearched.Add(path); return(false); } path = displayInfo.FilePath; return(true); }
protected virtual string GetPathFromGeneralName(ControllerContext controllerContext, List <ThemeableVirtualPathProviderViewEngine.ViewLocation> locations, string name, string controllerName, string areaName, string cacheKey, ref string[] searchedLocations) { Func <string, bool> func; Func <string, bool> func1 = null; Func <string, bool> func2 = null; string empty = string.Empty; searchedLocations = new string[locations.Count]; int num = 0; while (num < locations.Count) { ThemeableVirtualPathProviderViewEngine.ViewLocation item = locations[num]; string str = ""; str = item.Format(name, controllerName, areaName); if (!File.Exists(HttpContext.Current.Server.MapPath(str))) { str = item.Format(name, controllerName, areaName); } System.Web.WebPages.DisplayModeProvider displayModeProvider = base.DisplayModeProvider; string str1 = str; HttpContextBase httpContext = controllerContext.HttpContext; Func <string, bool> func3 = func1; if (func3 == null) { Func <string, bool> func4 = (string path) => this.FileExists(controllerContext, path); func = func4; func1 = func4; func3 = func; } DisplayInfo displayInfoForVirtualPath = displayModeProvider.GetDisplayInfoForVirtualPath(str1, httpContext, func3, controllerContext.DisplayMode); if (displayInfoForVirtualPath == null) { searchedLocations[num] = str; num++; } else { string filePath = displayInfoForVirtualPath.FilePath; searchedLocations = ThemeableVirtualPathProviderViewEngine._emptyLocations; empty = filePath; base.ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, this.AppendDisplayModeToCacheKey(cacheKey, displayInfoForVirtualPath.DisplayMode.DisplayModeId), empty); if (controllerContext.DisplayMode == null) { controllerContext.DisplayMode = displayInfoForVirtualPath.DisplayMode; } foreach (IDisplayMode mode in base.DisplayModeProvider.Modes) { if (mode.DisplayModeId != displayInfoForVirtualPath.DisplayMode.DisplayModeId) { IDisplayMode displayMode = mode; HttpContextBase httpContextBase = controllerContext.HttpContext; string str2 = str; Func <string, bool> func5 = func2; if (func5 == null) { Func <string, bool> func6 = (string path) => this.FileExists(controllerContext, path); func = func6; func2 = func6; func5 = func; } DisplayInfo displayInfo = displayMode.GetDisplayInfo(httpContextBase, str2, func5); string empty1 = string.Empty; if ((displayInfo == null ? false : displayInfo.FilePath != null)) { empty1 = displayInfo.FilePath; } base.ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, this.AppendDisplayModeToCacheKey(cacheKey, mode.DisplayModeId), empty1); } } break; } } return(empty); }