private void RefreshList() { lstFiles.Items.Clear(); foreach (string s in M.Elements.Keys) { if (!lstFiles.Items.Contains(s)) { lstFiles.Items.Add(s); } } lstMissing.Items.Clear(); lstObjects.Items.Clear(); foreach (string s in M.Elements.Keys) { if (!lstFiles.Items.Contains(s)) { ProgramElement E = M.Elements[s]; if (E.ElementType != ElementType.COMobject) { lstMissing.Items.Add(s); } else { lstObjects.Items.Add(s); System.Console.Out.WriteLine(s); } } } }
private void lstObjects_SelectedIndexChanged_1(object sender, EventArgs e) { ListBox LB = sender as ListBox; if (M.Elements.ContainsKey(LB.SelectedItem as string)) { lstDepends.Items.Clear(); lstSupports.Items.Clear(); ProgramElement E = M.Elements[LB.SelectedItem as string]; int Di = 0; foreach (string D in E.Depends.Keys) { lstDepends.Items.Add(D); Di++; } label4.Text = String.Format("Depends [{0:d}]", Di); int Si = 0; foreach (string S in E.Supports.Keys) { lstSupports.Items.Add(S); Si++; } label5.Text = String.Format("Supports [{0:d}]", Si); } }
private void NavigateToFile(string Filename, bool isForward) { if (Filename == null) { return; } txtAddressBar.Text = Filename; Filename = Filename.Trim(); if (!M.Elements.ContainsKey(Filename)) { MessageBox.Show("not found : " + Filename); return; } ProgramElement E = M.Elements[Filename]; lstDepends.Items.Clear(); lstSupports.Items.Clear(); foreach (ElementRelationship Dp in E.Depends.Values) { if (Dp.Supporter != null) { lstDepends.Items.Add(Dp.Supporter.name); } } //FillWithDescendents(lstSupports, E,1); foreach (ElementRelationship Sp in E.Supports.Values) { lstSupports.Items.Add(Sp.Dependent.name); } lstFiles.SelectedItem = Filename; if (isForward) { History.Push(Filename); } try { FileElement F = E as FileElement; cmdFindTextinFiles.Text = F.contents; if (this.Width < 1280) { this.Width = 1280; } } catch (Exception xe) { if (this.Width < 800) { this.Width = 800; } } }
private void lst_DoubleClick(object sender, EventArgs e) { ListBox LB = sender as ListBox; ProgramElement E = M.Elements[LB.SelectedItem as string]; try { FileElement F = E as FileElement; cmdFindTextinFiles.Text = F.contents; this.Width = 1280; } catch (Exception xe) { } }
public override string[] parse(ProgramElement obj) { Stack <string> S = new Stack <string>(); FileElement el; if ((el = obj as FileElement) == null ? true : false) { throw new Exception("Parser Type Miscast"); } foreach (Match m in Regex.Matches(el.contents, RegexString)) { S.Push(m.Groups[1].Value); } return(S.ToArray()); }
public override string[] parse(ProgramElement obj) { Stack <string> S = new Stack <string>(); FileElement el; if ((el = obj as FileElement) == null ? true : false) { throw new Exception("Parser Type Miscast"); } else { el.contents = el.contents.Replace(this.Matchstring, this.Changestring); } return(S.ToArray()); }
public override string[] parse(ProgramElement obj) { Stack <string> S = new Stack <string>(); FileElement el; if ((el = obj as FileElement) == null ? true : false) { throw new Exception("Parser Type Miscast"); } else { HtmlAgilityPack.HtmlDocument C = new HtmlAgilityPack.HtmlDocument(); C.LoadHtml(el.contents); el.contents = C.ToString(); } return(S.ToArray()); }
private void FillWithDescendents(ListBox L, ProgramElement R, int cnt) { String pad = ""; pad = pad.PadLeft(cnt * 2, ' '); foreach (ElementRelationship Dp in R.Depends.Values) { if (Dp.Supporter != null) { if (!L.Items.Contains(Dp.Supporter.name)) { L.Items.Add(pad + Dp.Supporter.name); } if (Dp.Supporter.Depends.Count > 0) { FillWithDescendents(L, Dp.Supporter, cnt + 1); } } } }
private void cmdSleuth_Click(object sender, EventArgs e) { if (txtSleuthFileNameList.Text.Length == 0 || !txtSleuthFileNameList.Text.Contains(',')) { MessageBox.Show("Need more than two filenames, seperated by a comma (,) to sleuth their common dependencies."); return; } string[] Filenames = txtSleuthFileNameList.Text.Split(','); if (Filenames.Length < 2) { MessageBox.Show("Need more than two filenames, seperated by a comma (,) to sleuth their common dependencies."); return; } if (M == null) { MessageBox.Show("System not Loaded"); return; } if (M.Elements == null) { MessageBox.Show("System not Loaded. Please load the system"); return; } Dictionary <string, HashSet <ProgramElement> > D = new Dictionary <string, HashSet <ProgramElement> >(); // List of dependencies of all items listen under txtSleuthFileNameList.Text List <ProgramElement> X = new List <ProgramElement>(); // List of all depended files listed - to control maximal flow foreach (string s in Filenames) { string t = M.RootFolderName + s; t = t.ToLower(); if (!M.Elements.ContainsKey(t)) { MessageBox.Show(String.Format("File name '{0}' not found in Systembase", t)); } else { HashSet <ProgramElement> H = new HashSet <ProgramElement>(); if (M.Elements.ContainsKey(t)) { ProgramElement E = M.Elements[t]; E.UltimatelyDependent(H); // this gets the list of all files that could be deemed dependent to E foreach (ProgramElement L in H) { if (!X.Contains(L)) { X.Add(L); } } } D.Add(t, H); } } int[] ConcurrenceCount = new int[X.Count]; // look at each hashset, and check each element of x. lstDepends.Items.Clear(); lstDepends.Sorted = true; for (int i = 0; i < X.Count; i++) { foreach (HashSet <ProgramElement> d in D.Values) { if (d.Contains(X[i])) { ConcurrenceCount[i]++; } } lstDepends.Items.Add(String.Format("{0}\t[ {1} ]", X[i].name, ConcurrenceCount[i])); if (ConcurrenceCount[i] == Filenames.Length) { MessageBox.Show(String.Format("{0} appears in {1} items.", X[i], ConcurrenceCount[i])); } } }
public abstract string[] parse(ProgramElement obj);
public static void AddParsers(ProgramElement El, string Ext) { if (El.Parsers == null) { El.Parsers = new LinkedList <ParseFeature>(); } switch (Ext.ToLower()) { case ".css": // url\('*([0-9a-z_\.\/:-]*)'*\); El.Parsers.AddFirst(new XformParser("\n", "\r\n", RelationShipType.RelationNone, "Standardise CRLF")); El.Parsers.AddLast(new RegexParser("url\\('*([0-9a-z_\\.\\/:-]*)'*\\);", RelationShipType.RelationOther, "Css Url Reference")); break; case ".cs": El.Parsers.AddLast(new RegexParser("using[\\s](.+);", RelationShipType.RelationCOM, "C# Includes")); break; case ".vbs": El.Parsers.AddLast(new RegexParser("call include([\"'](.*)[\"'])", RelationShipType.RelationCOM, "VBScript Includes")); El.Parsers.AddLast(new RegexParser("CreateObject([\"'](.*)[\"'])", RelationShipType.RelationCOM, "VBScript COM Object")); break; case ".asp": // <!--.*#include.*[virtual*].*="(.+)".*--> El.Parsers.AddLast(new RegexParser("<!--.*#include.*[virtual*].*=\"(.+)\".*-->", RelationShipType.RelationInclude, "ASP Includes")); // El.Parsers.AddLast(new RegexParser("(?i)Server.CreateObject(?-i)\\(\\\"(\\w+.\\w+)\\\"\\)", RelationShipType.RelationCOM, "Server.create object(multiple Languages)")); // El.Parsers.AddLast(new RegexParser("<link.+rel=\\\"stylesheet\\\".+href=\\\"(.*)\\\">", RelationShipType.RelationLink, "Link Tag, Stylesheet property(HTML)")); // break; case ".inc": El.Parsers.AddLast(new RegexParser("<!--.*#include.*[virtual*].*=\"(.+)\".*-->", RelationShipType.RelationInclude, "ASP Includes")); El.Parsers.AddLast(new RegexParser("(?i)Server.CreateObject(?-i)\\(\\\"(\\w+.\\w+)\\\"\\)", RelationShipType.RelationCOM, "Server.create object(multiple Languages)")); break; case ".js": El.Parsers.AddLast(new RegexParser("(?i)ActiveXObject(?-i)\\(\\\"(\\w+.\\w+)\\\"\\)", RelationShipType.RelationCOM, "new ActiveXObject Javascript")); break; case ".htm": El.Parsers.AddLast(new RegexParser("<link.+href=[\"'](.*)[\"']>", RelationShipType.RelationOther, "Link Tag")); El.Parsers.AddLast(new RegexParser("<script.+src=[\"'](.*)[\"']>", RelationShipType.RelationOther, "Link Tag")); break; case ".html": El.Parsers.AddFirst(new XformParser("\n", "\r\n", RelationShipType.RelationNone, "Standardise CRLF")); El.Parsers.AddLast(new RegexParser("<link.+href=[\"'](.*)[\"']>", RelationShipType.RelationOther, "Link Tag")); El.Parsers.AddLast(new RegexParser("<script.+src=[\"'](.*)[\"']>", RelationShipType.RelationOther, "Source Tag")); El.Parsers.AddLast(new RegexParser("<source.+src=[\"'](.*)[\"']>", RelationShipType.RelationNone, "Audio Tag")); break; case ".txt": break; case ".mustache": break; case ".php": El.Parsers.AddFirst(new XformParser("\n", "\r\n", RelationShipType.RelationNone, "Standardise CRLF")); El.Parsers.AddLast(new RegexParser("require_once*\\s*\\([\\S]*\\s*\\.\\s*'(.*)'\\);", RelationShipType.RelationInclude, "PHP Require Once")); El.Parsers.AddLast(new RegexParser("require*\\s*\\([\\S]*\\s*\\.\\s*'(.*)'\\);", RelationShipType.RelationInclude, "PHP Require ")); El.Parsers.AddLast(new RegexParser("include '(.*)';", RelationShipType.RelationInclude, "PHP include")); break; // } }