private void LogWarning(string message, params object[] args) { if (OnWarning != null) { OnWarning.Invoke(this, new NotificationMessage(string.Format(message, args))); } }
IEnumerator StartTimer() { while (_levelInProgress && _timeLeft > 0) { yield return(new WaitForSeconds(1)); _timeLeft -= 1; OnTimeChanged?.Invoke(_timeLeft); if (_nextWarningIndex < TimeLeftWhenWarningPlays.Count) { if (_nextWarningIndex > 0 && _timeLeft > TimeLeftWhenWarningPlays[_nextWarningIndex - 1]) { _nextWarningIndex--; } if (_timeLeft == TimeLeftWhenWarningPlays[_nextWarningIndex]) { OnWarning?.Invoke(_timeLeft); _nextWarningIndex++; } } if (_timeLeft == 0) { WhenTimeRunsOut(); } } }
/* * It's button func on WarningButton */ public void OnWarningBackClicked() { audioM.Click(); OnWarning?.Invoke(this, new WarningArgs { action = WindowAction.Close }); }
/* * It's button func on WarningButton */ public void OnWarningConfirmClicked() { audioM.Click(); // SEND WARNING TO US Debug.LogWarning("Warning on the question!"); OnWarning?.Invoke(this, new WarningArgs { action = WindowAction.Confirm }); }
//public Player(ISkin skin) : base(skin) //{ //} public override Task <bool> Play(bool loop) { return(Task.Run(() => { if (!Locked && Items.Count > 0) { Playing = true; PlayerStartedEvent?.Invoke(Items, null, Locked, Volume, Playing); } if (Playing) { int numLoop = 0; numLoop = (loop == false) ? 1 : 5; //Skin.NewScreen(); for (int j = 0; j < numLoop; j++) { foreach (var item in Items) { try { ViewPlayList(item); SongStartedEvent?.Invoke(Items, item, Locked, Volume, Playing); soundPlayer.SoundLocation = item.Path; soundPlayer.PlaySync(); //soundPlayer.Play(); } catch (FileNotFoundException) { OnWarning?.Invoke("Файл не найден"); throw new FailedToPlayException("Файл не найден", item.Path); } catch (InvalidOperationException) { OnWarning?.Invoke("Проверте расширение файла"); throw new System.Exception("Проверте расширение файла"); } Console.ResetColor(); } } Playing = false; System.Threading.Thread.Sleep(2000); } return Playing; })); //else Skin.Render("Player is Locked"); }
private void InitListeners() { m_nativeEngine.OnInfo += (string message) => { OnInfo?.Invoke(message); }; m_nativeEngine.OnWarning += (string message) => { OnWarning?.Invoke(message); }; m_nativeEngine.OnError += (string message) => { OnError?.Invoke(message); }; }
internal static void Log(string msg, LogType type = LogType.Info) { switch (type) { case LogType.Info: OnInfo?.Invoke(msg); break; case LogType.Warning: OnWarning?.Invoke(msg); break; case LogType.Error: OnError?.Invoke(msg); break; } }
private void OnEngineHttpMessageEnd([In][MarshalAs(UnmanagedType.LPStr)] string requestHeaders, uint requestHeadersLength, [In] IntPtr requestBody, uint requestBodyLength, [In][MarshalAs(UnmanagedType.LPStr)] string responseHeaders, uint responseHeadersLength, [In] IntPtr responseBody, uint responseBodyLength, ref bool shouldBlock, NativeCustomResponseStreamWriter customBlockResponseStreamWriter) { byte[] requestBodyManaged = null; byte[] responseBodyManaged = null; if (requestBody != IntPtr.Zero) { requestBodyManaged = new byte[requestBodyLength]; Marshal.Copy(requestBody, requestBodyManaged, 0, requestBodyManaged.Length); } if (responseBody != IntPtr.Zero) { responseBodyManaged = new byte[requestBodyLength]; Marshal.Copy(responseBody, responseBodyManaged, 0, responseBodyManaged.Length); } ResponseWriter thisWriter = (byte[] responseData) => { var myNativeWriter = customBlockResponseStreamWriter; if (myNativeWriter == null) { OnWarning?.Invoke("Native response writers exhausted."); } myNativeWriter?.Invoke(responseData, (uint)responseData.Length); GC.KeepAlive(myNativeWriter); }; var shouldBlockManaged = false; HttpMessageEndCallback?.Invoke(requestHeaders, requestBodyManaged, responseHeaders, responseBodyManaged, out shouldBlockManaged, thisWriter); shouldBlock = shouldBlockManaged; }
private void OnEngineHttpMessageBegin([In][MarshalAs(UnmanagedType.LPStr)] string requestHeaders, uint requestHeadersLength, [In] IntPtr requestBody, uint requestBodyLength, [In][MarshalAs(UnmanagedType.LPStr)] string responseHeaders, uint responseHeadersLength, [In] IntPtr responseBody, uint responseBodyLength, ref uint nextAction, NativeCustomResponseStreamWriter customBlockResponseStreamWriter) { byte[] requestBodyManaged = null; byte[] responseBodyManaged = null; if (requestBody != IntPtr.Zero) { requestBodyManaged = new byte[requestBodyLength]; Marshal.Copy(requestBody, requestBodyManaged, 0, requestBodyManaged.Length); } if (responseBody != IntPtr.Zero) { responseBodyManaged = new byte[requestBodyLength]; Marshal.Copy(responseBody, responseBodyManaged, 0, responseBodyManaged.Length); } ResponseWriter thisWriter = (byte[] responseData) => { var myNativeWriter = customBlockResponseStreamWriter; if (myNativeWriter == null) { OnWarning?.Invoke("Native response writers exhausted."); } myNativeWriter?.Invoke(responseData, (uint)responseData.Length); GC.KeepAlive(myNativeWriter); }; var managedNextAction = ProxyNextAction.AllowAndIgnoreContentAndResponse; HttpMessageBeginCallback?.Invoke(requestHeaders, requestBodyManaged, responseHeaders, responseBodyManaged, out managedNextAction, thisWriter); nextAction = (uint)managedNextAction; }
protected bool Warn(string message, bool returnVal = false) { OnWarning?.Invoke(message); return(returnVal); }
public static void Warning(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) => OnWarning?.Invoke(message, file, line);
private void OnEngineWarning(string message, uint messageLength) { OnWarning?.Invoke(message); }
public async void Create() { try { HttpResponseMessage response = await _registrationClient.GetAsync("https://www.instagram.com"); var responseCookies = _cookieContainer.GetCookies(new Uri("https://www.instagram.com")).Cast <Cookie>().ToList(); _registrationClient.DefaultRequestHeaders.Add("Origin", "https://www.instagram.com"); _registrationClient.DefaultRequestHeaders.Add("Referer", "https://www.instagram.com/"); _registrationClient.DefaultRequestHeaders.Add("X-Requested-With", "XMLHttpRequest"); _registrationClient.DefaultRequestHeaders.Add("X-Instagram-AJAX", "1"); _registrationClient.DefaultRequestHeaders.Add("X-CSRFToken", responseCookies[0].Value); HtmlDocument htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(await response.Content.ReadAsStringAsync()); var javascriptEngine = new Jurassic.ScriptEngine(); object evalResult = javascriptEngine.Evaluate("(function() { var window = {}; " + htmlDocument.DocumentNode.SelectNodes("//script[@type='text/javascript']")[4].InnerHtml + " return window._sharedData; })()"); JObject scriptJson = JObject.Parse(JSONObject.Stringify(javascriptEngine, evalResult)); _cookieContainer.Add(new Cookie("ig_pr", scriptJson["display_properties_server_guess"]["pixel_ratio"].ToString()) { Domain = "instagram.com" }); _cookieContainer.Add(new Cookie("ig_vw", scriptJson["display_properties_server_guess"]["viewport_width"].ToString()) { Domain = "instagram.com" }); NameValueCollection queryString = HttpUtility.ParseQueryString(string.Empty); queryString["first_name"] = _instagramUsername; queryString["username"] = _instagramUsername; queryString["password"] = _instagramPassword; queryString["email"] = _instagramEmail; StringContent queryStringContent = new StringContent(queryString.ToString()); queryStringContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); HttpResponseMessage creationResponse = await _registrationClient.PostAsync("https://www.instagram.com/accounts/web_create_ajax/", queryStringContent); JObject responseJson = JObject.Parse(await creationResponse.Content.ReadAsStringAsync()); if (responseJson["account_created"].ToObject <bool>()) { if (OnSuccess != null) { OnSuccess.BeginInvoke(this, null, null); } } else { if (responseJson["errors"] != null) { StringBuilder stringBuilder = new StringBuilder(); foreach (JProperty error in responseJson["errors"]) { stringBuilder.Append(error.Value[0] + " "); } if (OnWarning != null) { OnWarning.BeginInvoke(stringBuilder.ToString(), null, null); } } } } catch (Exception ioException) when(ioException is IOException) { } catch (Exception requestException) when(requestException is HttpRequestException) { if (requestException.InnerException is WebException) { if (((WebException)requestException.InnerException).Status == WebExceptionStatus.ConnectFailure) { if (OnFailure != null) { OnFailure.BeginInvoke(string.Format("'{0}' failed to connect to Instagram.", Proxy), null, null); } } } } catch (Exception ex) { //ignore the other exceptions } }