public static void Create_Layout(string linkProject) { var doc = new HtmlWeb().Load(linkProject); String Html = "", head = "", header = "", footer = "", script = ""; foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//link")) { head += RenderActionResults.RenderHeader(link); } foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//body")) { foreach (var node in link.ChildNodes) { if (node.Name == "header") { header = header_renderHTML(node); } if (node.Name == "div") { } if (node.Name == "footer") { footer = footer_renderHTML(node); } if (node.Name == "script") { script += script_renderHTML(node); } } } Html = Layout_renderHTML(head, header, footer, script); FileFolder.File(Property.RacinePathViews + "/Shared/_Layout.cshtml", Html); }
public static String script_renderHTML(HtmlNode script) { foreach (var att in script.Attributes) { if (att.Name == "src") { Library.Property.ASPScripts.links.Add(att.Value); String linkpath = ""; if (att.Value.Contains("//cdnjs") || att.Value.Contains("//code")) { if (att.Value.Contains("https:")) { linkpath = att.Value; } else { linkpath = "http:" + att.Value; } } else { linkpath = Property.RacineURL + "/" + att.Value; } var subpath = att.Value.Split('/'); FileFolder.downloadfile(linkpath, "scripts/js/" + subpath[subpath.Length - 1]); att.Value = "~/Content/scripts/js/" + subpath[subpath.Length - 1]; } } return(script.OuterHtml + Environment.NewLine); }
public void Create_Layout() { var urlViews = Property.RacinePathContent + "/" + Property.ASPModel.NameProject + "/Views"; Property.RacinePathViews = urlViews; FileFolder.Folder(urlViews); FileFolder.Folder(urlViews + "/Shared"); RenderLayout.Create_Layout(Property.ASPModel.LinkProject); }
public void Create_Folder_ActionResult() { var urlViews = Property.RacinePathContent + "/" + Property.ASPModel.NameProject + "/Views"; Property.RacinePathViews = urlViews; FileFolder.Folder(urlViews); foreach (var controller in Property.ASPModel.Controllers) { FileFolder.Folder(urlViews + "/" + controller.Name); RenderActionResults.Create_View(controller.Name, controller.actionResults); } }
public static String RenderHeaderStyle(HtmlNode node) { String head = ""; if (node.Name == "link") { var attcss = node.Attributes.Where(x => x.Name == "rel" && x.Value == "stylesheet").FirstOrDefault(); if (attcss != null) { var att = node.Attributes.Where(x => x.Name == "href").FirstOrDefault(); if (!Library.Property.ASPStyles.links.Contains(att.Value)) { if (att.Name == "href") { String linkpath = ""; if (att.Value.Contains("//code.jquery.com")) { linkpath = "http:" + att.Value; } else if (att.Value.Contains("https://fonts.")) { linkpath = att.Value; att.Value = linkpath; } else { linkpath = Property.RacineURL + "/" + att.Value; var subpath = att.Value.Split('/'); FileFolder.downloadfile(linkpath, "css/" + subpath[subpath.Length - 1]); att.Value = "~/Content/css/" + subpath[subpath.Length - 1]; } head += node.OuterHtml + Environment.NewLine; } } } } return(head); }
public static void Create_View(String controllerName, List <ASPActionResult> actionResults) { foreach (var actionResult in actionResults) { string contentscss = GetPageCodeCss(actionResult.Link); string contentsJs = GetPageCodeJs(actionResult.Link); string contents = GetPageCode(actionResult.Link); string codeHtmlFinal = ""; codeHtmlFinal += Environment.NewLine + "{" + Environment.NewLine; codeHtmlFinal += Environment.NewLine + "@ViewBag.Title ='" + actionResult.Name + "';" + Environment.NewLine; codeHtmlFinal += Environment.NewLine + "}" + Environment.NewLine; codeHtmlFinal += Environment.NewLine + "@section styles{" + Environment.NewLine; codeHtmlFinal += Environment.NewLine + contentscss + Environment.NewLine; codeHtmlFinal += Environment.NewLine + "}" + Environment.NewLine; codeHtmlFinal += Environment.NewLine + "@section scripts{" + Environment.NewLine; codeHtmlFinal += Environment.NewLine + contentsJs + Environment.NewLine; codeHtmlFinal += Environment.NewLine + "}" + Environment.NewLine; codeHtmlFinal += Environment.NewLine + contents + Environment.NewLine; FileFolder.File(Property.RacinePathViews + "/" + controllerName + "/" + actionResult.Name + ".cshtml", codeHtmlFinal); } }
public void Create_Folder_Controller() { var urlcontroller = Property.RacinePathContent + "/" + Property.ASPModel.NameProject + "/Controllers"; FileFolder.Folder(urlcontroller); Property.RacinePathControllers = urlcontroller; RenderControllers renderControllers = new RenderControllers(); foreach (var controller in Property.ASPModel.Controllers) { var controllerstring = renderControllers.GetUsing(); controllerstring += "\n"; controllerstring += renderControllers.GetNamespace(); controllerstring += renderControllers.Open(); controllerstring += renderControllers.GetControllers(controller.Name); controllerstring += renderControllers.Open(); controllerstring += renderControllers.GetActionResults(controller.actionResults); controllerstring += renderControllers.Close(); controllerstring += renderControllers.Close(); FileFolder.File(urlcontroller + "/" + controller.Name + "Controller.cs", controllerstring); } }
private static string RenderHeaderScript(HtmlNode node) { String script = ""; if (node.Name == "script") { var attjs = node.Attributes.Where(x => x.Name == "src").FirstOrDefault(); if (attjs != null) { if (!Library.Property.ASPScripts.links.Contains(attjs.Value)) { String linkpath = ""; if (attjs.Value.Contains("//cdnjs") || attjs.Value.Contains("//code")) { if (attjs.Value.Contains("https:")) { linkpath = attjs.Value; } else { linkpath = "http:" + attjs.Value; } } else { linkpath = Property.RacineURL + "/" + attjs.Value; } var subpath = attjs.Value.Split('/'); FileFolder.downloadfile(linkpath, "scripts/js/" + subpath[subpath.Length - 1]); attjs.Value = "~/Content/scripts/js/" + subpath[subpath.Length - 1]; script += node.OuterHtml + Environment.NewLine; } } } return(script); }
public void Create_Folder() { FileFolder.Folder(Property.RacinePathContent + "/" + Property.ASPModel.NameSpace); }