/// <summary> /// This code (and the two methods above) were taken from https://bitbucket.org/duanyao/moz-devtools-patch /// with thanks to Duane Yao. /// It starts up a server that allows FireFox to be used to inspect and debug the content of geckofx windows. /// See the ReadMe in remoteDebugging for instructions. /// Note that this should NOT be done in production. There are security issues. /// </summary> static void StartDebugServer() { GeckoPreferences.User["devtools.debugger.remote-enabled"] = true; // It seems these files MUST be in a subdirectory of the application directory. At least, I haven't figured out // how it can be anywhere else. Therefore the build copies the necessary files there. // If you try to change it, be aware that the chrome.manifest file contains the name of the parent folder; // if you rename the folder and don't change the name there, you get navigation errors in the code below and // remote debugging doesn't work. var chromeDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "remoteDebugging"); registerChromeDir(chromeDir); var browser = new GeckoWebBrowser(); browser.NavigationError += (s, e) => { Console.WriteLine(">>>StartDebugServer error: " + e.ErrorCode.ToString("X")); browser.Dispose(); }; browser.DocumentCompleted += (s, e) => { Console.WriteLine(">>>StartDebugServer complete"); browser.Dispose(); }; browser.Navigate("chrome://remoteDebugging/content/moz-remote-debug.html"); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged /// resources; <c>false</c> to release only unmanaged resources. /// </param> /// ----------------------------------------------------------------------------------- protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { if (m_browser != null) { #if Old SHDocVw.WebBrowser_V1 axDocumentV1 = m_browser.GetOcx() as SHDocVw.WebBrowser_V1; if (axDocumentV1 != null) { axDocumentV1.BeforeNavigate -= new SHDocVw.DWebBrowserEvents_BeforeNavigateEventHandler(OnBeforeNavigate); } #endif m_browser.Dispose(); } if (components != null) { components.Dispose(); } } m_url = null; m_browser = null; base.Dispose(disposing); }
protected virtual void Dispose(bool disposing) { Logging.Debug("CSLProcessorOutputConsumer::Dispose({0}) @{1}", disposing, dispose_count); try { if (dispose_count == 0) { // Get rid of managed resources web_browser?.Dispose(); } web_browser = null; brd = null; user_argument = null; position_to_inline.Clear(); inline_to_positions.Clear(); position_to_text.Clear(); bibliography.Clear(); logs.Clear(); } catch (Exception ex) { Logging.Error(ex); } ++dispose_count; }
public void SpiderMonkeyEntryPointTests() { foreach (var entryPoint in EntryPoints()) { var dummy = new GeckoWebBrowser(); dummy.CreateControl(); var dummyHandle = dummy.Handle; // Try us around the using because, AutoJSContext can throw exception caused by the junk arguments we pass to EntryPoints. try { using (var cx = new AutoJSContext(GlobalJSContextHolder.BackstageJSContext)) { entryPoint.Value(IntPtr.Zero); } } catch (Exception e) { if (e is EntryPointNotFoundException) { Assert.Fail(String.Format("{0} EntryPoint is wrong: {1}", entryPoint.Value, e.Message)); } } dummy.Dispose(); } }
protected virtual void Dispose(bool disposing) { Logging.Debug("CSLProcessorOutputConsumer::Dispose({0}) @{1}", disposing, dispose_count); WPFDoEvents.InvokeInUIThread(() => { WPFDoEvents.SafeExec(() => { if (dispose_count == 0) { // Get rid of managed resources web_browser?.Dispose(); } }); WPFDoEvents.SafeExec(() => { web_browser = null; brd = null; user_argument = null; }); WPFDoEvents.SafeExec(() => { position_to_inline.Clear(); inline_to_positions.Clear(); position_to_text.Clear(); bibliography.Clear(); logs.Clear(); }); ++dispose_count; }); }
public void AfterEachTestTearDown() { _browser.Dispose(); if (File.Exists(_tempPath)) { File.Delete(_tempPath); } }
/// <summary> /// Closing the form exit the LEAN engine too. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LeanWinForm_FormClosed(object sender, FormClosedEventArgs e) { Log.Trace("LeanWinForm(): Form closed."); #if !__MonoCS__ _geckoBrowser.Dispose(); #endif Environment.Exit(0); }
protected void AddToolbarAndBrowserToTab(TabPage tabPage, GeckoWebBrowser browser) { TextBox urlbox = new TextBox(); urlbox.Top = 0; urlbox.Width = 200; Button nav = new Button(); nav.Text = "Go"; nav.Left = 200; Button newTab = new Button(); newTab.Text = "NewTab"; newTab.Left = 200 + nav.Width; Button closeTab = new Button(); closeTab.Text = "Close"; closeTab.Left = 200 + nav.Width + newTab.Width; Button scrollDown = new Button { Text = "Down", Left = closeTab.Left + 250 }; Button scrollUp = new Button { Text = "Up", Left = closeTab.Left + 330 }; scrollDown.Click += (s, e) => { browser.Window.ScrollByPages(1); }; scrollUp.Click += (s, e) => { browser.Window.ScrollByPages(-1); }; nav.Click += delegate { // use javascript to warn if url box is empty. if (string.IsNullOrEmpty(urlbox.Text.Trim())) { browser.Navigate("javascript:alert('hey try typing a url!');"); } browser.Navigate(urlbox.Text); tabPage.Text = urlbox.Text; }; newTab.Click += delegate { AddTab(); }; closeTab.Click += delegate { m_tabControl.Controls.Remove(tabPage); browser.Dispose(); }; tabPage.Controls.Add(urlbox); tabPage.Controls.Add(nav); tabPage.Controls.Add(newTab); tabPage.Controls.Add(closeTab); tabPage.Controls.Add(browser); tabPage.Controls.Add(scrollDown); tabPage.Controls.Add(scrollUp); }
public MainForm() { InitializeComponent(); string url = Prompt.ShowDialog("https://58406979-c515-4181-b3ee-24546dba0f72.htmlpasta.com/", "Please enter the URL"); if (url == "-1") { Environment.Exit(0); } IntPtr progman = FindWindow("Progman", null); IntPtr result = IntPtr.Zero; SendMessageTimeout(progman, 0x052C, new IntPtr(0), IntPtr.Zero, 0, 1000, out result); IntPtr p = IntPtr.Zero; EnumWindows(new EnumWindowsProc((tophandle, topparamhandle) => { p = FindWindowEx(tophandle, IntPtr.Zero, "SHELLDLL_DefView", ""); if (p != IntPtr.Zero) { workerw = FindWindowEx(IntPtr.Zero, tophandle, "WorkerW", ""); } return(true); }), IntPtr.Zero); this.Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width; this.Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; //* Xpcom.Initialize(); geckoWebBrowser = new GeckoWebBrowser { Dock = DockStyle.Fill }; this.Controls.Add(geckoWebBrowser); if (url != "-1") { geckoWebBrowser.Navigate(url); geckoWebBrowser.Load += (s, e) => { SetParent(this.Handle, workerw); }; } else { geckoWebBrowser.Dispose(); this.Close(); Application.Exit(); } }
static void StartDebugServer() { GeckoPreferences.User["devtools.debugger.remote-enabled"] = true; //see <geckofx_src>/chrome dir RegisterChromeDir(Path.GetFullPath(Path.Combine(XULRunnerLocator.GetXULRunnerLocation(), "../../chrome"))); var browser = new GeckoWebBrowser(); browser.NavigationError += (s, e) => { Console.Error.WriteLine("StartDebugServer error: 0x" + e.ErrorCode.ToString("X")); browser.Dispose(); }; browser.DocumentCompleted += (s, e) => { Console.WriteLine("StartDebugServer completed"); browser.Dispose(); }; //see <geckofx_src>/chrome/debugger-server.html browser.Navigate("chrome://geckofx/content/debugger-server.html"); }
public override void OnClose(ref bool canceled) { string changed; try { using (var jsContext = new AutoJSContext(_gecko.Window)) { jsContext.EvaluateScript("editor.changed", out changed); if (changed == "true" && IsRunMode == false) { var dialogResult = MessageBox.Show(MainWindow.Instance, $"“{this.Title}”已修改,是否保存?", "", MessageBoxButton.YesNoCancel); if (dialogResult == MessageBoxResult.Yes) { string info; jsContext.EvaluateScript("editor.getSaveInfo()", out info); var json = info.ToJsonObject <Newtonsoft.Json.Linq.JToken>(); if (json.Value <string>("name").IsBlank() || json.Value <string>("code").IsBlank()) { MessageBox.Show(this.GetParentByName <Window>(null), "请点击左上角设置图标,设置监视画面的名称、编号!"); canceled = true; return; } closeAfterSave = true; this.save(info); canceled = true; return; } else if (dialogResult == MessageBoxResult.Cancel) { canceled = true; return; } } } } catch (Exception ex) { } foreach (var client in _clients) { client.Released = true; client.NetClient.Close(); } _gecko.Dispose(); base.OnClose(ref canceled); }
protected virtual void Closing() { this.Load -= _loadHandler; this.BackColorChanged -= _backColorChangedHandler; this.ForeColorChanged -= _foreColorChangedHandler; _focusElement = null; if (_timer != null) { _timer.Stop(); _timer = null; } if (_browser != null) { _browser.DomKeyDown -= _domKeyDownHandler; _browser.DomKeyUp -= _domKeyUpHandler; _browser.DomFocus -= _domFocusHandler; _browser.DomBlur -= _domBlurHandler; _browser.DocumentCompleted -= _domDocumentCompletedHandler; #if __MonoCS__ _browser.DomClick -= _domClickHandler; _browser.Dispose(); _browser = null; #else if (Xpcom.IsInitialized) { _browser.Dispose(); _browser = null; } #endif } _loadHandler = null; _domKeyDownHandler = null; _domKeyUpHandler = null; _domFocusHandler = null; _domDocumentCompletedHandler = null; #if __MonoCS__ _domClickHandler = null; #endif }
private void CloseActiveTab() { // получаем активную вкладку TabPage selectedTab = this.tcBrowsersTabs.SelectedTab; if (selectedTab == null) { return; } // получаем ссылку на браузер GeckoWebBrowser webBrowser = this.GetWebBrowserByActiveTab(); // удаляем со словаря this._wbPages.Remove(webBrowser); // уничтожаем браузер webBrowser.Dispose(); webBrowser = null; // удаляем вкладку this.tcBrowsersTabs.TabPages.Remove(this.tcBrowsersTabs.SelectedTab); // принудительно запускаем сборщик мусора GC.Collect(); }
public void FromPtr_JsObject_ConvertedToJsValOfExpectedObject() { var browser = new GeckoWebBrowser(); var unused = browser.Handle; Assert.IsNotNull(browser); browser.TestLoadHtml("hello world."); Assert.Null(browser.Editor); using (var context = new AutoJSContext(browser.Window)) { var jsObject = context.ConvertCOMObjectToJSObject((nsISupports)browser.Document.DomObject); var jsVal = JsVal.FromPtr(jsObject); Assert.IsTrue(jsVal.IsObject); Assert.AreEqual(JSType.JSTYPE_OBJECT, jsVal.Type); Assert.AreEqual("[object HTMLDocument]", jsVal.ToString()); // Verify that converting back to ComObject yields expected object. var documentObject = (nsIDOMHTMLDocument)jsVal.ToObject(); Assert.AreEqual(browser.Document.TextContent, new GeckoDocument(documentObject).TextContent); } browser.Dispose(); }
private void donetimer_Tick(object sender, EventArgs e) { /* Updates the process for the end user */ //Set volume to Zero, otherwise the user will hear Plays.tv in the background because of gecko waveOutSetVolume(IntPtr.Zero, 0); if (done4) { //DONE Infotimer.Stop(); donetimer.Stop(); step4.ForeColor = Color.Lime; loadingind.Image = Properties.Resources.checkmark_96px; downloadingrn.Visible = true; downloadingrn.Text = "Done!"; infolbl.Show(); infolbl.Text = "Please consider donating if you support this project"; didyouknow.Hide(); paypal.Show(); geckoWebBrowser.Dispose(); } else if (done3) { //Stage 3 if (videosfound != 0 && continuenow == false) { continuenow = true; } else { step3.ForeColor = Color.Lime; downloadingrn.Visible = true; downloadingrn.Text = "Downloaded: " + (downdone) + "/" + videosfound; if ((downdone == videosfound) && (Math.Round(downloadeddone) == Math.Round(downloaded))) { done4 = true; } } } else if (done2) { //Stage 2 step2.ForeColor = Color.Lime; downloadingrn.Visible = true; if (!downloadingrn.Text.Contains("Retrying:")) { if (!downloadingrn.Text.Contains("Plays servers are slow today...")) { downloadingrn.Text = "Loading..."; } } } else if (done1) { //Stage 1 step1.ForeColor = Color.Lime; downloadingrn.Visible = true; downloadingrn.Text = "Logging in..."; } }
static void _aboutMemory_FormClosed(object sender, FormClosedEventArgs e) { _memoryBrowser.Dispose(); }
protected override void AfterEachTestTearDown() { base.AfterEachTestTearDown(); _browser.Dispose(); }
public void Close() { browser.Dispose(); }
public void AfterEachTestTearDown() { _gwb.Dispose(); }
protected void AddToolbarAndBrowserToTab(TabPage tabPage, GeckoWebBrowser browser) { TextBox urlbox = new TextBox(); urlbox.Top = 0; urlbox.Width = 200; //urlbox.Text = "https://getfirebug.com/releases/lite/1.2/"; //urlbox.Text = "file:///G:/en2/build/view/demo.html"; //urlbox.Text = "file:///G:/en2/build/view/demo.html"; Button nav = new Button(); nav.Text = "Go"; nav.Left = 200; Button newTab = new Button(); newTab.Text = "NewTab"; newTab.Left = 200 + nav.Width; Button closeTab = new Button(); closeTab.Text = "Close"; closeTab.Left = 200 + nav.Width + newTab.Width; browser.DocumentCompleted += (se, ev) => { if (html == string.Empty) { string url = "https://dictionary.cambridge.org/grammar/british-grammar/above-or-over", text = string.Empty, _fix_lib = string.Empty; Debug.WriteLine("#-> " + url); text = f_link_getHtmlOnline(url); string head = text.Split(new string[] { "<body" }, StringSplitOptions.None)[0], s = "<div" + text.Substring(head.Length + 5); int posH1 = s.ToLower().IndexOf("<h1"); if (posH1 != -1) { s = s.Substring(posH1, s.Length - posH1); } head = Html.f_html_Format(url, head); s = Html.f_html_Format(url, s); //if (File.Exists("view/fix.html")) _fix_lib = File.ReadAllText("view/fix.html"); text = head.Replace("<head>", @"<head><meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />" + _fix_lib) + "<body><article id=___body><!--START_BODY-->" + s + "<!--END_BODY--></article></body></html>"; html = s; } browser.Document.Body.InnerHtml = html; //Debug.WriteLine(browser.Document.Body.InnerHtml) string firebuglite_bookmark_run = "javascript:var firebug=document.createElement('script');firebug.setAttribute('src','http://localhost:56789/firebug-lite-compressed.js');document.body.appendChild(firebug);(function(){if(window.firebug.version){firebug.init();}else{setTimeout(arguments.callee);}})();void(firebug);"; browser.Navigate(firebuglite_bookmark_run); }; nav.Click += delegate { // use javascript to warn if url box is empty. if (string.IsNullOrEmpty(urlbox.Text.Trim())) { browser.Navigate("javascript:alert('hey try typing a url!');"); } browser.Navigate(urlbox.Text); tabPage.Text = urlbox.Text; }; newTab.Click += delegate { AddTab(); }; closeTab.Click += delegate { m_tabControl.Controls.Remove(tabPage); browser.Dispose(); }; tabPage.Controls.Add(urlbox); tabPage.Controls.Add(nav); tabPage.Controls.Add(newTab); tabPage.Controls.Add(closeTab); tabPage.Controls.Add(browser); }
public void AfterEachTestTearDown() { _browser.Dispose(); Marshal.ReleaseComObject(m_instance); }
public void AfterEachTest() { _browser.Dispose(); _form.Dispose(); }
/// <summary> /// 运行js代码 /// </summary> /// <typeparam name="T">返回值类型</typeparam> /// <param name="jsCode">一段js代码。如:return data.name;</param> /// <param name="data">传到js里面的对象,js可以通过data.*直接使用此参数</param> /// <returns></returns> public T Run <T>(string jsCode, object data) { if (httpServer == null) { throw new Exception("请先调用JsRunner.StartVirtualWebServer启动web服务器"); } var gecko = new GeckoWebBrowser(); gecko.CreateControl(); //加入apicloud.db模拟器 List <ISimulator> simulators = new List <ISimulator>(); foreach (var t in SimulatorTypes) { var obj = (ISimulator)Activator.CreateInstance(t); obj.Init(gecko); simulators.Add(obj); } bool loadFinished = false; gecko.NavigationError += (s, e) => { }; gecko.NSSError += (s, e) => { }; gecko.DocumentCompleted += (s, e) => { loadFinished = true; }; using (System.IO.MemoryStream ms = new MemoryStream()) { System.IO.StreamWriter sw = new StreamWriter(ms, Encoding.UTF8); sw.WriteLine("<!DOCTYPE html>"); sw.WriteLine("<html>"); sw.WriteLine("<body>"); foreach (var simulator in simulators) { simulator.OnWritingScript(sw); } foreach (var path in JsFiles) { if (path[1] == ':') { if (File.Exists(path) == false) { throw new Exception($"文件{path}不存在"); } sw.WriteLine("<script src=\"file:///" + path + "\" type=\"text/javascript\"></script>"); } else { sw.WriteLine("<script src=\"" + path + "\" type=\"text/javascript\"></script>"); } } if (!string.IsNullOrEmpty(this.Html)) { sw.WriteLine(this.Html); } string result; if (_runJsOnWindowLoad) { sw.WriteLine("</body>"); sw.WriteLine("</html>"); sw.Dispose(); var pageid = Guid.NewGuid().ToString("N"); VisitHandler.HtmlContents.TryAdd(pageid, ms.ToArray()); ms.Dispose(); gecko.Navigate($"{ServerUrl}Jack.JSUnitTest?id={pageid}"); while (!loadFinished) { System.Threading.Thread.Sleep(10); System.Windows.Forms.Application.DoEvents(); } var jsContext = new AutoJSContext(gecko.Window); var js = @" (function(d){ var result = (function(data){ try{ " + jsCode + @" } catch(e) { if(typeof e === 'string') return { ______err : e , line:0 }; else { var msg = e.message; if(e.name) msg = e.name + ',' + msg; return { ______err :msg , line:e.lineNumber }; } } })(d); return JSON.stringify(result); })(" + (data == null ? "null" : Newtonsoft.Json.JsonConvert.SerializeObject(data)) + @"); "; jsContext.EvaluateScript(js, out result); jsContext.Dispose(); } else { var guidName = "v" + Guid.NewGuid().ToString("N"); var js = @" <script lang='ja'> var " + guidName + @" = (function(data){ try{ " + jsCode + @" } catch(e) { if(typeof e === 'string') return { ______err : e , line:0 }; else { var msg = e.message; if(e.name) msg = e.name + ',' + msg; return { ______err :msg , line:e.lineNumber }; } } })(" + Newtonsoft.Json.JsonConvert.SerializeObject(data) + @"); " + guidName + @"=JSON.stringify(" + guidName + @"); </script> "; sw.WriteLine(js); sw.WriteLine("</body>"); sw.WriteLine("</html>"); sw.Dispose(); var pageid = Guid.NewGuid().ToString("N"); VisitHandler.HtmlContents.TryAdd(pageid, ms.ToArray()); ms.Dispose(); gecko.Navigate($"{ServerUrl}Jack.JSUnitTest?id={pageid}"); while (!loadFinished) { System.Threading.Thread.Sleep(10); System.Windows.Forms.Application.DoEvents(); } var jsContext = new AutoJSContext(gecko.Window); js = guidName; jsContext.EvaluateScript(js, out result); jsContext.Dispose(); } gecko.Dispose(); if (result.StartsWith("{\"______err\":")) { var errObj = Newtonsoft.Json.JsonConvert.DeserializeObject <Newtonsoft.Json.Linq.JObject>(result); string errMsg = errObj.Value <string>("______err"); //int lineNumber = errObj.Value<int>("line") - 3; throw new Exception(errMsg); } if (result.StartsWith("\"") == false && typeof(T) == typeof(string)) { return((T)(object)result); } if (result == "undefined") { return(default(T)); } return(Newtonsoft.Json.JsonConvert.DeserializeObject <T>(result)); } }
void f_brow_Init() { brow_Domain = brow_URL.Split('/')[2]; browser = new GeckoWebBrowser(); browser.Dock = DockStyle.Fill; browser.NavigationError += (s, e) => { Debug.WriteLine("StartDebugServer error: 0x" + e.ErrorCode.ToString("X")); browser.Dispose(); }; browser.DocumentCompleted += (s, e) => { Debug.WriteLine("StartDebugServer completed"); browser.Dispose(); }; brow_Transparent = new ControlTransparent() { Location = new Point(0, 0), Size = new Size(999, 999) }; Panel toolbar = new Panel() { Dock = DockStyle.Top, Height = TOOLBAR_HEIGHT, BackColor = SystemColors.Control, Padding = new Padding(3, 3, 0, 3) }; brow_ShortCutBar = new Panel() { Dock = DockStyle.Top, Height = SHORTCUTBAR_HEIGHT, BackColor = SystemColors.Control, Padding = new Padding(0) }; brow_UrlTextBox = new TextBoxWaterMark() { WaterMark = "HTTP://...", Dock = DockStyle.Fill, Height = 20, Font = font_Title, BorderStyle = BorderStyle.None, BackColor = SystemColors.Control }; brow_UrlTextBox.KeyDown += (se, ev) => { if (ev.KeyCode == Keys.Enter) { f_brow_Go(brow_UrlTextBox.Text.Trim()); } }; brow_UrlTextBox.MouseDoubleClick += (se, ev) => { brow_UrlTextBox.Text = string.Empty; }; var btn_ToggleTab = new Button() { Text = tab_IconToggle, Width = 19, Height = 20, Dock = DockStyle.Right }; btn_ToggleTab.MouseClick += (se, ev) => { f_tab_Toggle(); }; toolbar.Controls.AddRange(new Control[] { brow_UrlTextBox, new Label() { Dock = DockStyle.Right, Width = 100 }, btn_ToggleTab }); this.Controls.AddRange(new Control[] { brow_Transparent, browser, brow_ShortCutBar, toolbar, }); }
public void AfterEachTestTearDown() { _context.Dispose(); _browser.Dispose(); }
private void FrmMangaBrowser_FormClosing(object sender, FormClosingEventArgs e) { browser.Dispose(); }
public void AfterEachTestTearDown() { _context.Dispose(); _gwb.Dispose(); }
private void web_browser_ConsoleMessage(object sender, ConsoleMessageEventArgs e) { Logging.Debug特("JAVASCRIPT CONSOLE MESSAGE: {0}", e.Message); try { if (finished_processing) { Logging.Info("Finished processing, so ignoring InCite JavaScript error: {0}", e.Message); return; } if (e.Message.Contains("Permission denied")) { Logging.Info("Skipping known exception: {0}", e.Message); return; } if (e.Message.Contains("SyntaxError")) { finished_processing = true; Logging.Info("Acting on InCite syntax error: {0}", e.Message); System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"line:\s+(\d+)\s+column:\s+(\d+)\s+"); System.Text.RegularExpressions.MatchCollection matches = regex.Matches(e.Message); if (0 < matches.Count) { int line = Int32.Parse(matches[0].Groups[1].Value); int pos = Int32.Parse(matches[0].Groups[2].Value); string[] citations_javascript_lines = citations_javascript.Split(new char[] { '\n' }); int min = (int)Math.Max(0, line - 1 - 15); int max = (int)Math.Min(citations_javascript_lines.Length, line - 1 + 5); StringBuilder sb_error_region = new StringBuilder(); sb_error_region.AppendFormat("Syntax error ({1},{2}): {0}\n", e.Message, line, pos); for (int i = min; i <= max; ++i) { string indicator = (i == line - 1) ? "?????? " : " "; sb_error_region.AppendFormat("{0}{1}\n", indicator, citations_javascript_lines[i]); } error_message = sb_error_region.ToString(); } else { error_message = e.Message; } Logging.Info("Calling the BibliographyReadyDelegate"); success = false; brd(this); Logging.Info("Called the BibliographyReadyDelegate"); } if (e.Message.Contains("INCITE_FINISHED")) { finished_processing = true; Logging.Info("Acting on signalling InCite JavaScript error: {0}", e.Message); Logging.Info("Received citeproc results"); { string json_output_encoded = web_browser.DomDocument.GetHtmlElementById("ObjOutput").InnerHtml; string json_output = WebUtility.HtmlDecode(json_output_encoded); JObject json = JObject.Parse(json_output); // Pull out the inlines { Logging.Info("Pulling out the inlines"); foreach (var inline in json["inlines"]) { string key = (string)inline["citation"]["citationID"]; int total_items_affected_by_key = inline["citation_output"].Count(); foreach (var citation_output in inline["citation_output"]) { int position = (int)citation_output[0]; string text = (string)citation_output[1]; SetInline(key, position, text, total_items_affected_by_key); } } } // Pull out the bibliography { Logging.Info("Pulling out the bibliography settings"); // Do these results lack a bibliography? JToken has_bibliography = json["bibliography"] as JToken; if (null != has_bibliography && JTokenType.Boolean == has_bibliography.Type) { Logging.Info("This style has no bibliography: json bibliography node is {0}", has_bibliography); } else { var settings = json["bibliography"][0]; SetBibliographySettings( (int)(settings["maxoffset"] ?? 0), (int)(settings["entryspacing"] ?? 0), (int)(settings["linespacing"] ?? 0), (int)(settings["hangingindent"] ?? 0), Convert.ToString(settings["second-field-align"] ?? ""), (string)(settings["bibstart"] ?? ""), (string)(settings["bibend"] ?? "") ); Logging.Info("Pulling out the bibliography"); var bibliography = json["bibliography"][1]; foreach (var bib in bibliography) { SetBibliography((string)bib); } } } Logging.Debug特("Calling the BibliographyReadyDelegate"); success = true; brd(this); Logging.Debug特("Called the BibliographyReadyDelegate"); } if (finished_processing) { // Clean up if (null != web_browser) { Logging.Debug特("Disposing of web browser for InCite CSL processing"); web_browser.Dispose(); web_browser = null; } } } } catch (Exception ex) { Logging.Error(ex, "There was a problem in the callback from citeproc"); } }
public void AfterEachTestTearDown() { browser.Dispose(); }
public void AfterEachTestTearDown() { Marshal.ReleaseComObject(_memoryService); _browser.Dispose(); }