static void Main(string[] args) { string path; if (args.Length > 0) path = args[0]; else path = Directory.GetCurrentDirectory(); Publish pub = new Publish(); pub.setPubDir("./publish"); pub.setDupDir("../../duplicate"); pub.setTemplate("../../Resources/Template.htm"); Navigate nav = new Navigate(); nav.go(path, "*.cs"); List<string> files = nav.getSources(); // To Obtain list of fully qualified filenames to be processed DirectoryInfo di1; if (!Directory.Exists(pub.getDupDir())) di1 = Directory.CreateDirectory(pub.getDupDir()); else di1 = new DirectoryInfo(pub.getDupDir()); foreach (string file in files) { FileInfo File = new FileInfo(file); DirectoryInfo di; if (!Directory.Exists(pub.getPubDir())) di = Directory.CreateDirectory(pub.getPubDir()); else di = new DirectoryInfo(pub.getPubDir()); try { List<CodeAnalysis.Elem> table = pub.Locate(File);//find locations where spans need to be inserted if (table != null) { FileInfo dupFile = pub.Spans(table, File); if (dupFile != null) { pub.makePage(dupFile, di); } } } catch(Exception ex) { Console.WriteLine("An error occured: " + ex.Message); continue; } pub.CreateDirList(di); } }
static void Main(string[] args) { Console.Write("\n Testing Text Inserter And Publisher"); Console.Write("\n ======================\n"); DirectoryInfo di, di1; Publish pub = new Publish(); pub.setPubDir("./publish"); pub.setDupDir("./duplicate"); pub.setTemplate("../../Resources/template.htm"); if (!Directory.Exists(pub.getPubDir())) di = Directory.CreateDirectory(pub.getPubDir()); else di = new DirectoryInfo(pub.getPubDir()); pub.getDupDir(); Console.WriteLine(di); if (!Directory.Exists(pub.getDupDir())) di1 = Directory.CreateDirectory(pub.getDupDir()); else di1 = new DirectoryInfo(pub.getDupDir()); Console.WriteLine(di1); FileInfo f = new FileInfo("../../Publish.cs"); List<CodeAnalysis.Elem> table=pub.Locate(f); FileInfo dupFile=pub.Spans(table, f); StreamReader sr = new StreamReader(dupFile.FullName); string line = sr.ReadToEnd(); Console.WriteLine(line); if (dupFile != null) { pub.makePage(dupFile, di); } sr.Close(); pub.CreateDirList(di); Console.WriteLine("File Published in the following directory:"); Console.WriteLine("==========================================="); Console.WriteLine(pub.getPubDir()); Console.WriteLine("==========================================="); }