public void Test() { var useXWV = ReadResource <bool>("Use XWebView as http service?"); IHttpService http; if (useXWV) { //XWV client used to execute scripts and prevent ban. if (_xwv == null) { _xwv = new OffScreenCefSharpXWebViewProvider().Resolve(XWebViewVisibility.Hidden).Result; } http = new XWebViewHttpService(_xwv); } else { http = new HttpService(new HttpClient()); } var parser = new BestChangeParser(http); var list = parser.Parse("https://www.bestchange.ru/bitcoin-to-bitcoin-cash.html").Result; Cmd.WriteLine(JsonConvert.SerializeObject(list, Formatting.Indented)); Cmd.WriteLine("Call number: " + _callNum++); Cmd.WriteLine("---------------"); }
IXWebView GetXWV() { if (_xwv == null) { _xwv = new OffScreenCefSharpXWebViewProvider().Resolve().Result; } return(_xwv); }
public TradingView(IXWebView xwv) { UnpackResources(); XWV = xwv ?? throw new ArgumentNullException(nameof(xwv)); XWV.Visibility = XWebViewVisibility.Visible; var thread = new Thread(async(obj) => { while (!IsDisposed) { try { await Task.Delay(LoopRefreshTimeout); if (LoopRefreshEnabled) { var ctx = XWV.ThreadSync.Invoke(() => TypedContext); await RefreshAsync(); } } catch (Exception ex) { } } }); thread.Priority = ThreadPriority.BelowNormal; thread.Start(); Action <double, double> timeRangeChangedHandler = (double startTime, double endTime) => { var startDateTime = TimeExtensions.FromUniversalDateTime(startTime); var endDateTime = TimeExtensions.FromUniversalDateTime(endTime); var args = new TimeRangeChangedEventArgs() { StartTime = startDateTime, EndTime = endDateTime }; XWV.ThreadSync.Invoker.Invoke(() => { TimeRangeChanged?.Invoke(this, args); }); }; xwv.BindToJs(timeRangeChangedHandler, "timeRangeUpdated", "window"); }