/// <summary> /// 生成包含生成Url函数的javascript文件,用于前端生成Url时使用。 /// </summary> /// <param name="globalConfig"></param> public static void GetUrlRouteJsContent(NFinal.Config.Global.GlobalConfig globalConfig) { UrlRouteJsModel model = new UrlRouteJsModel(); model.formatControllerDictionary = formatControllerDictionary; string directory = NFinal.IO.Path.MapPath(globalConfig.projectType, "/Scripts"); if (!System.IO.Directory.Exists(directory)) { System.IO.Directory.CreateDirectory(directory); } NFinal.IO.FileWriter fileWriter = new IO.FileWriter(System.IO.Path.Combine(directory, "Url.js")); NFinal.Url.UrlRouteJs urlRouteJsTemplate = new UrlRouteJs(fileWriter, model); urlRouteJsTemplate.Execute(); fileWriter.Dispose(); }
/// <summary> /// 生成调试html,用浏览器打开这些html,可以直接调试其目录名对应的控制器行为所对应的函数 /// </summary> /// <param name="globalConfig"></param> public static void GenerateActionDebugHtml(NFinal.Config.Global.GlobalConfig globalConfig) { NFinal.IO.FileWriter fileWriter; DebugData debugData; string fileName; string relativePath; string absolutePath; if (globalConfig.debug.directory == null) { globalConfig.debug.directory = "Debug"; } foreach (var controller in formatControllerDictionary) { Type controllerType = Type.GetTypeFromHandle(controller.Key); relativePath = "/" + globalConfig.debug.directory.TrimStart('/') + "/" + controllerType.Namespace.Replace('.', '/') + "/" + ActionUrlHelper.GetControllerName(controllerType); absolutePath = NFinal.IO.Path.GetProjectPath(relativePath); if (!System.IO.Directory.Exists(absolutePath)) { System.IO.Directory.CreateDirectory(absolutePath); } foreach (var method in controller.Value) { fileName = System.IO.Path.Combine(absolutePath, method.Key + ".html"); if (!System.IO.File.Exists(fileName)) { debugData = new NFinal.Url.DebugData(); debugData.classFullName = controllerType.FullName; debugData.methodName = method.Key; debugData.formatData = method.Value; debugData.debugUrl = globalConfig.debug.url; using (fileWriter = new IO.FileWriter(fileName)) { NFinal.Url.Debug debugTemplate = new Debug(fileWriter, debugData); debugTemplate.Execute(); } } } } }