Beispiel #1
0
		static public void Register(ICefWinBrowser browser)
		{
			if (browser == null) throw new ArgumentNullException(nameof(browser));
			long id = browser.Agent.Browser.Identifier;
			if (_browsers.ContainsKey(id))
			{
				WriteDebugLine("Warning,call Register again, id:" + id);
				return;
			}
			_browsers[id] = browser;
			browser.Disposed += delegate (object sender, EventArgs e)
			{
				long rid = ((ICefWinBrowser)sender).Agent.Browser.Identifier;
				_browsers.TryRemove(rid, out var value);
			};
		}
Beispiel #2
0
        static public ICefWinBrowser FindBrowser(this BlazorSession session)
        {
            WebCustomizeSession wcs = (WebCustomizeSession)session;
            long CefWinBrowserId;

            if (!long.TryParse(wcs.HttpContextAccessor.HttpContext.Request.Cookies["CefWinBrowserId"], out CefWinBrowserId))
            {
                //BlazorSession.Current.Toast("Failed to get browserid");
                return(CefWin.MainBrowser);
            }
            ICefWinBrowser browser = CefWin.FindBrowser(CefWinBrowserId);

            if (browser == null)
            {
                //BlazorSession.Current.Toast("Failed to find browser : " + CefWinBrowserId);
                return(CefWin.MainBrowser);
            }
            return(browser);
        }