/// <summary> /// Reads in the template and generates the appropriate html /// </summary> public static void Generate() { try { InitJS(); WebUIDir root = new WebUIDir(); root.m_path = "."+Path.DirectorySeparatorChar+"webui"+Path.DirectorySeparatorChar+"template"; if (!Directory.Exists("."+Path.DirectorySeparatorChar+"webui")) { Directory.CreateDirectory("."+Path.DirectorySeparatorChar+"webui"); } ParseDirectory(root); CopyFromTemplate(root); if (log.IsInfoEnabled) if (log.IsInfoEnabled) log.Info("WebUI Generation initialized!"); } catch (Exception e) { if (log.IsErrorEnabled) log.Error("WebUI Generation", e); } }
/// <summary> /// Copies all files from .\webui\template to .\webui\generated /// </summary> /// <param name="dir">Parent directory</param> private static void CopyFromTemplate(WebUIDir dir) { string path = dir.m_path.Replace("." + Path.DirectorySeparatorChar + "webui" + Path.DirectorySeparatorChar + "template", "." + Path.DirectorySeparatorChar + "webui" + Path.DirectorySeparatorChar + "generated"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } foreach (WebUIDir d in dir.m_dirs) { CopyFromTemplate(d); } foreach (string s in dir.m_files) { FileInfo fi = new FileInfo(s); string fpath = s.Replace("." + Path.DirectorySeparatorChar + "webui" + Path.DirectorySeparatorChar + "template", "." + Path.DirectorySeparatorChar + "webui" + Path.DirectorySeparatorChar + "generated"); if (fi.Extension.IndexOf("html") != -1 || fi.Extension.IndexOf("htm") != -1) { GenerateJS(s); } else { fi.CopyTo(fpath, true); } } }
/// <summary> /// Reads in the template and generates the appropriate html /// </summary> public static void Generate() { try { InitJS(); WebUIDir root = new WebUIDir(); root.m_path = "." + Path.DirectorySeparatorChar + "webui" + Path.DirectorySeparatorChar + "template"; if (!Directory.Exists("." + Path.DirectorySeparatorChar + "webui")) { Directory.CreateDirectory("." + Path.DirectorySeparatorChar + "webui"); } ParseDirectory(root); CopyFromTemplate(root); if (log.IsInfoEnabled) { if (log.IsInfoEnabled) { log.Info("WebUI Generation initialized!"); } } } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("WebUI Generation", e); } } }
/// <summary> /// Parses a directory for all source files /// </summary> /// <param name="parent"></param> private static void ParseDirectory(WebUIDir parent) { string[] dirs = Directory.GetDirectories(parent.m_path); IEnumerator iter = dirs.GetEnumerator(); while (iter.MoveNext()) { WebUIDir dir = new WebUIDir(); dir.m_path = (string)(iter.Current); ParseDirectory(dir); parent.m_dirs.Add(dir); } parent.m_files = Directory.GetFiles(parent.m_path, "*.*"); }
/// <summary> /// Parses a directory for all source files /// </summary> /// <param name="parent"></param> private static void ParseDirectory(WebUIDir parent) { string[] dirs = Directory.GetDirectories(parent.m_path); IEnumerator iter = dirs.GetEnumerator(); while (iter.MoveNext()) { WebUIDir dir = new WebUIDir(); dir.m_path = (string)iter.Current; ParseDirectory(dir); parent.m_dirs.Add(dir); } parent.m_files = Directory.GetFiles(parent.m_path, "*.*"); }