internal void AddResponseInspectorsToTabControl(TabControl oTC) { List <TabPage> list = new List <TabPage>(); foreach (DictionaryEntry entry in this.m_ResponseInspectors) { try { TabPage page = new TabPage(); Inspector2 inspector = (Inspector2)Activator.CreateInstance((entry.Value as Inspector2).GetType()); page = new TabPage { Font = new Font(page.Font.FontFamily, CONFIG.flFontSize), Tag = inspector }; inspector.AddToTab(page); list.Add(page); continue; } catch (Exception exception) { FiddlerApplication.Log.LogFormat("[Fiddler] Failure initializing Response Inspector: {0}\n{1}", new object[] { exception.Message, exception.StackTrace }); continue; } } oTC.TabPages.AddRange(list.ToArray()); }
internal void ScanInspectors() { string path = CONFIG.GetPath("Inspectors"); try { TabPage key; Evidence securityEvidence = Assembly.GetExecutingAssembly().Evidence; foreach (FileInfo info in new DirectoryInfo(path).GetFiles()) { if (info.FullName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) && !info.FullName.StartsWith("_", StringComparison.OrdinalIgnoreCase)) { Assembly assembly; try { if (CONFIG.bRunningOnCLRv4) { assembly = Assembly.LoadFrom(info.FullName); } else { assembly = Assembly.LoadFrom(info.FullName, securityEvidence); } } catch (Exception exception) { FiddlerApplication.LogAddonException(exception, "Failed to load " + info.FullName); goto Label_0283; } try { if (assembly.IsDefined(typeof(RequiredVersionAttribute), false)) { RequiredVersionAttribute customAttribute = (RequiredVersionAttribute)Attribute.GetCustomAttribute(assembly, typeof(RequiredVersionAttribute)); int num = Utilities.CompareVersions(customAttribute.RequiredVersion, CONFIG.FiddlerVersionInfo); if (num > 0) { FiddlerApplication.DoNotifyUser(string.Format("The Inspectors in {0} require Fiddler v{1} or later. (You have v{2})\n\nPlease install the latest version of Fiddler from http://www.fiddler2.com.\n\nCode: {3}", new object[] { info.FullName, customAttribute.RequiredVersion, CONFIG.FiddlerVersionInfo, num }), "Inspector Not Loaded"); } else { foreach (System.Type type in assembly.GetExportedTypes()) { if ((!type.IsAbstract && !type.IsInterface) && (type.IsPublic && type.IsSubclassOf(typeof(Inspector2)))) { try { TabPage page = new TabPage(); Inspector2 inspector = (Inspector2)Activator.CreateInstance(type); page = new TabPage { Font = new Font(page.Font.FontFamily, CONFIG.flFontSize), Tag = inspector }; if (inspector is IRequestInspector2) { this.m_RequestInspectors.Add(page, inspector); } else if (inspector is IResponseInspector2) { this.m_ResponseInspectors.Add(page, inspector); } } catch (Exception exception2) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure loading {0} inspector from {1}: {2}\n\n{3}", new object[] { type.Name, info.FullName.ToString(), exception2.Message, exception2.StackTrace }), "Inspector Failed"); } } } } } } catch (Exception exception3) { FiddlerApplication.DebugSpew(string.Format("[Fiddler] Failure loading inspectors from {0}: {1}", info.FullName.ToString(), exception3.Message)); } Label_0283 :; } } List <TabPage> list = new List <TabPage>(); List <TabPage> list2 = new List <TabPage>(); foreach (DictionaryEntry entry in this.m_RequestInspectors) { try { key = (TabPage)entry.Key; ((Inspector2)entry.Value).AddToTab(key); list.Add(key); key.Validating += new CancelEventHandler(this.m_Viewer.actValidateRequest); key.CausesValidation = true; continue; } catch (Exception exception4) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure initializing Request Inspector: {0}\n{1}", exception4.Message, exception4.StackTrace), "Initialization Error"); continue; } } bool flag = false; foreach (DictionaryEntry entry2 in this.m_ResponseInspectors) { try { key = (TabPage)entry2.Key; ((Inspector2)entry2.Value).AddToTab(key); if (key.Text.Contains("SyntaxView")) { flag = true; } list2.Add(key); key.Validating += new CancelEventHandler(this.m_Viewer.actValidateResponse); key.CausesValidation = true; continue; } catch (Exception exception5) { FiddlerApplication.DoNotifyUser(string.Format("[Fiddler] Failure initializing Response Inspector: {0}\n{1}", exception5.Message, exception5.StackTrace), "Initialization Error"); continue; } } if (!flag && FiddlerApplication.Prefs.GetBoolPref("fiddler.inspectors.response.AdvertiseSyntaxView", true)) { this._CreateSyntaxViewAd(); } InspectorComparer comparer = new InspectorComparer(this.m_RequestInspectors); list.Sort(comparer); comparer = new InspectorComparer(this.m_ResponseInspectors); list2.Sort(comparer); this.m_tabsRequest.TabPages.AddRange(list.ToArray()); this.m_tabsResponse.TabPages.AddRange(list2.ToArray()); } catch (Exception exception6) { FiddlerApplication.DoNotifyUser(string.Format("Failure loading inspectors: {0}", exception6.Message), "Error"); } }