private PluginTreeNode GetControllerNode(RequestContext requestContext, string controllerName) { Route route = requestContext.RouteData.Route as Route; if (route == null) { return(null); } var controllerPath = string.Empty; var area = VirtualPathHelper.GetArea(requestContext.RouteData); if (string.IsNullOrWhiteSpace(area)) { controllerPath = PluginPath.Combine(ROOT_CONTROLLERS_PATH, controllerName); } else { controllerPath = PluginPath.Combine(ROOT_CONTROLLERS_PATH, area, controllerName); } requestContext.RouteData.DataTokens["area"] = area; requestContext.RouteData.DataTokens["controller.path"] = controllerPath; return(_pluginContext.PluginTree.Find(controllerPath)); }
private string CombinePath(string directoryName, string controllerName, string name, string extension) { string filePath; if (string.IsNullOrEmpty(extension)) { if (string.IsNullOrEmpty(controllerName)) { filePath = name; } else { filePath = string.Format("{0}.{1}", controllerName, name); } } else { if (extension[0] != '.') { extension = '.' + extension; } if (name.EndsWith(extension, StringComparison.OrdinalIgnoreCase)) { if (string.IsNullOrEmpty(controllerName)) { filePath = name; } else { filePath = string.Format("{0}.{1}", controllerName, name); } } else { if (string.IsNullOrEmpty(controllerName)) { filePath = name + extension; } else { filePath = string.Format("{0}.{1}{2}", controllerName, name, extension); } } } //为了跨操作系统方便处理,一律对文件名部分做全小写处理。注意:目录部分必须保持真实大小写! if (string.IsNullOrEmpty(directoryName)) { filePath = filePath.ToLowerInvariant(); } else { filePath = Path.Combine(directoryName, filePath.ToLowerInvariant()); } //将物理路径转换成虚拟路径 return(VirtualPathHelper.ToVirtualPath(filePath)); }