Acrolinx.Sdk.Sidebar.AcrolinxPlugin.OnAfterObjectSet C# (CSharp) Метод

OnAfterObjectSet() публичный Метод

public OnAfterObjectSet ( ) : void
Результат void
        public void OnAfterObjectSet()
        {
            System.Diagnostics.Trace.WriteLine("OnAfterObjectSet");

            sidebar.Eval("if (!window.console) { window.console = {} }; window.console.logOld = window.console.log; window.console.log = function(msg) { window.external.Log(msg); }" );
            sidebar.Eval( "window.onerror = function(msg, url, line, col, error) { window.external.OnError(msg, url, line, col, error); }" );
            //The next line would have the effect that the sidebar exchanges objects instead of strings. This seem to fail in case of .NET internet explorer web control...
            webBrowser.Document.InvokeScript("eval", new object[] { "window.acrolinxPlugin =   {requestInit: function(){ window.external.requestInit()}, onInitFinished: function(finishResult) {window.external.onInitFinished(JSON.stringify(finishResult))}, configure: function(configuration) { window.external.configure(JSON.stringify(configuration)) }, requestGlobalCheck: function() { window.external.requestGlobalCheck() }, onCheckResult: function(checkResult) {window.external.onCheckResult(JSON.stringify(checkResult)) }, selectRanges: function(checkId, matches) { window.external.selectRanges(checkId, JSON.stringify(matches))}, replaceRanges: function(checkId, matchesWithReplacements) { window.external.replaceRanges(checkId, JSON.stringify(matchesWithReplacements)) }, download: function(downloadInfo) { window.external.download(JSON.stringify(downloadInfo))}, openWindow: function(openWindowParameters) { window.external.openWindow(JSON.stringify(openWindowParameters)) }}; "});
        }

Usage Example

        private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            System.Diagnostics.Trace.WriteLine("Sidebar navigated to: " + e.Url);

            bool sidebarRevisionFound = false;
            foreach (HtmlElement element in webBrowser.Document.GetElementsByTagName("meta"))
            {
                if ("sidebar-revision".Equals(("" + element.GetAttribute("name")).ToLower()))
                {
                    sidebarRevisionFound = true;
                    break;
                }
            }

            if (!sidebarRevisionFound)
            {
                System.Diagnostics.Trace.WriteLine("Could not find sidebar at URL: " + e.Url);

                string internalUrl = GetInternalUrl();

                if (internalUrl.StartsWith("res://ieframe.dll/"))
                {
                    System.Diagnostics.Trace.WriteLine("Loaded page seems to be an IE error page. URL: " + e.Url + " / " + internalUrl);

                    SidebarSourceNotReachable?.Invoke(this, new SidebarUrlEvenArgs(e.Url));
                    return;
                }
            }

            labelImage.Visible = false;
            DocumentLoaded?.Invoke(this, new SidebarDocumentLoadedEvenArgs(sidebarRevisionFound, e.Url));
            if (!sidebarRevisionFound)
            {
                return;
            }

            if (webBrowser.ObjectForScripting == null)
            {
                acrolinxPlugin = new AcrolinxPlugin(webBrowser, this);
                webBrowser.ObjectForScripting = acrolinxPlugin;
                acrolinxPlugin.OnAfterObjectSet();
            }

            SidebarLoaded?.Invoke(this, new SidebarUrlEvenArgs(e.Url));
        }