/// <summary> /// Pauses the specified wrokers. /// </summary> /// <param name="wait">if set to <c>true</c> waits for the operation to complete.</param> /// <param name="read">if set to <c>true</c> executes the opration on the reading worker.</param> /// <param name="decode">if set to <c>true</c> executes the opration on the decoding worker.</param> /// <param name="render">if set to <c>true</c> executes the opration on the rendering worker.</param> public void Pause(bool wait, bool read, bool decode, bool render) { if (IsDisposed) { return; } var tasks = new Task[(read ? 1 : 0) + (decode ? 1 : 0) + (render ? 1 : 0)]; var index = 0; if (read) { tasks[index] = Reading.PauseAsync(); index++; } if (decode) { tasks[index] = Decoding.PauseAsync(); index++; } if (render) { tasks[index] = Rendering.PauseAsync(); } if (wait) { Task.WaitAll(tasks); } }
static void Main(string[] args) { Dictionary <char, double> map = new Dictionary <char, double>(); Dictionary <char, string> dictionary = new Dictionary <char, string>(); WorkWithCollections useDict = new WorkWithCollections(textPath); // Highlight original symbols. useDict.DistinctSymbols(ref map); // Init tree with map. Tree tree = new Tree(map); // Init dictionary with tree. tree.InitDictionary(dictionary); useDict.DictionaryView(dictionary); Console.WriteLine(); // Encode text with dictionary. string encodedString = useDict.CodingText(dictionary); // Encode dictionary && encoded string to file. Coding drBits = new Coding(encodedFile); drBits.Encode(dictionary, encodedString); // Decode encodedFile to resultado file Decoding decoding = new Decoding(resultadoNormal); Console.WriteLine(decoding.Decode(encodedFile).Length); Console.WriteLine("Average code length: " + useDict.AverageCodeLen(map, dictionary)); Console.WriteLine("Entropy: " + useDict.Entropy(map)); }
public Response Request(Request request) { var httpResponse = GetHttpWebResponse(request); var buff = GetResponseBuff(httpResponse); var response = new Response(); response.StatusCode = httpResponse.StatusCode; response.Headers = httpResponse.Headers; response.RequestUri = request.Uri; response.ResponseUri = httpResponse.ResponseUri; response.IsRaw = request.IsRaw; response.Method = request.Method; if (request.IsRaw) { response.Data = buff; } else { var result = Decoding.GetStringFromBuff(buff, httpResponse, request.Charset); response.Charset = result.CharSet; response.Data = result.Body; } httpResponse.Close(); return(response); }
private void button3_Click(object sender, EventArgs e) { /// /// 获取webbrowser里的图片 /// HTMLDocument html = (HTMLDocument)webBrowser1.Document.DomDocument;//注意是HTMLDocument而不是HtmlDocument //寻找验证码图片,因为没有ID所以得自己定位 HtmlElement elem = webBrowser1.Document.GetElementById("icode"); IHTMLControlElement img = (IHTMLControlElement)elem.DomElement; IHTMLControlRange range = (IHTMLControlRange)((HTMLBody)html.body).createControlRange(); range.add(img); range.execCommand("Copy", false, null); if (Clipboard.ContainsImage()) { Image pic = Clipboard.GetImage(); this.pictureBox1.Image = pic; Bitmap bitmap = (Bitmap)pic.Clone(); bitmap.Save(Application.StartupPath + "\\numbers\\" + DateTime.Now.Ticks.ToString() + ".bmp"); Decoding decode = new Decoding(); string result = decode.Decode(bitmap); label1.Text = result; } }
static void Main(string[] args) { var tr = TransponderReceiverFactory.CreateTransponderDataReceiver(); var decoding = new Decoding(tr); while (true) { Thread.Sleep(1000); } }
static void Main(string[] args) { ITransponderReceiver transponderDataReceiver = TransponderReceiverFactory.CreateTransponderDataReceiver(); var decoder = new Decoding(transponderDataReceiver); decoder.TrackDataReady += (o, trackArgs) => PrintTracks(trackArgs.TrackData); System.Console.ReadLine(); }
public void SetUp() { _eventCalled = 0; list = new List <string>(); _receiver = Substitute.For <ITransponderReciever>(); _ftracks = new List <IUpdate>(); _uut = new Decoding(_receiver); list.Add("Test;111;222;333;20190325135320120"); _fakeData = new TransponderReceiverDataEventArgs(list); _uut._updateCreated += (o, args) => _ftracks = args.updatetracks; { ++_eventCalled; } }
static void Main(string[] args) { string text; int printCount; Console.WriteLine("Text:"); string input = Console.ReadLine(); if (input[0] == '\\') { text = GetTextFromFile(input.Substring(1)).ToLower(); } else { text = input.ToLower(); } Console.Write("Print top how many?> "); printCount = int.Parse(Console.ReadLine()); List <Decoding> decodings = GetAllDecodings(text); decodings.Sort((valueA, valueB) => valueA.difference.CompareTo(valueB.difference)); if (printCount > decodings.Count) { printCount = decodings.Count; } for (int i = 0; i < printCount; i++) { Decoding decoding = decodings[i]; Console.WriteLine($"Difference: {decoding.difference}"); Console.WriteLine($"Decrypted by: {decoding.multiplier}x + {decoding.offset}"); int inverseMultiplier = InverseMultiplier(decoding.multiplier); int decryptOffset = (inverseMultiplier * (-decoding.offset)); decryptOffset = (decryptOffset + ((Math.Abs(decryptOffset) / validCharacters.Length) * validCharacters.Length) + validCharacters.Length) % validCharacters.Length; Console.WriteLine($"Encrypted by: {inverseMultiplier}x + {decryptOffset}"); Console.WriteLine(decoding.text); Console.WriteLine(); } Console.WriteLine("Program Finished"); Console.ReadKey(); }
public Response Request(Request request) { if (!string.IsNullOrEmpty(request.Ip)) { if (!IPHelper.IsHostIPAddress(IPAddress.Parse(request.Ip))) { return(new Response { IsRaw = false, StatusCode = HttpStatusCode.BadRequest, Data = "specified Ip is invalid!" }); } } var httpResponse = GetHttpWebResponse(request); var buff = GetResponseBuff(httpResponse); var response = new Response(); response.StatusCode = httpResponse.StatusCode; response.Headers = WebHeader.FromWebHeader(httpResponse.Headers); response.RequestUri = request.Uri; response.ResponseUri = httpResponse.ResponseUri; response.IsRaw = request.IsRaw; response.Method = request.Method; if (request.UseCookie) { SetCookie(request, httpResponse.Headers.Get("Set-Cookie")); } if (request.IsRaw) { response.Data = buff; } else { var result = Decoding.GetStringFromBuff(buff, httpResponse, request.Charset); response.Charset = result.CharSet; response.Data = result.Body; response.Cookie = GetCookie(request); } httpResponse.Close(); return(response); }
/// <summary> /// buffers a frame into mpg123. /// </summary> void BufferFrame() { for (int i = 0; i < 1;) { AudioFrame frame = m_Source.GetNextFrame(); if (frame == null) { break; } Decoding?.Invoke(this, new AudioFrameEventArgs(frame)); if (frame.IsAudio) { m_DecodeFifoBuffer.Enqueue(frame.Data); i++; } } }
/// <summary> /// request /// </summary> /// <param name="request">crawl request</param> /// <returns>crawl response</returns> public Response Request(Request request) { Logger.GetLogger(request.Elect).Info("request " + request.Uri.ToString() + " with ip:" + request.Ip + (request.Proxy != null ? (" proxy:" + request.Proxy.Ip + ":" + request.Proxy.Port) : "")); SimulateBrowser(request); try { if (request.RunJS) { var p = new PhantomCrawler(); var res = p.Request(request); if (request.UseCookie && res.Headers != null) { var cookies = res.Headers.Where(m => m.Name == "Set-Cookie").Select(m => m.Value).ToList(); if (cookies.Count > 0) { var c = string.Join("", cookies).Replace("\n", ","); SetCookie(request, c); res.Cookie = GetCookie(request); } } res.ElectInfo = request.Elect; res.Request = request; Logger.GetLogger(request.Elect).Info(request.Uri.ToString() + " response status is " + res.StatusCode.ToString()); return(res); } if (!string.IsNullOrEmpty(request.Ip)) { if (!IPHelper.IsHostIPAddress(IPAddress.Parse(request.Ip))) { return(new Response { IsRaw = false, StatusCode = HttpStatusCode.BadRequest, Data = "specified Ip is invalid!" }); } } var httpResponse = GetHttpWebResponse(request); if (httpResponse == null) { var r = new Response(); r.StatusCode = HttpStatusCode.BadRequest; r.Data = "httpResponse is null"; return(r); } var buff = GetResponseBuff(httpResponse); var response = new Response(); response.StatusCode = httpResponse.StatusCode; response.Headers = WebHeader.FromWebHeader(httpResponse.Headers); response.Request = request; response.ResponseUri = httpResponse.ResponseUri; //response.Method = request.Method; if (!string.IsNullOrEmpty(httpResponse.ContentType)) { response.IsRaw = MimeDetect.IsRaw(httpResponse.ContentType); } else { response.IsRaw = MimeDetect.IsRaw(httpResponse.ResponseUri); } if (request.UseCookie) { SetCookie(request, httpResponse.Headers.Get("Set-Cookie")); } if (response.IsRaw) { response.Data = buff; } else { var result = Decoding.GetStringFromBuff(buff, httpResponse, request.Charset); response.Charset = result.CharSet; response.Data = result.Body; response.Cookie = GetCookie(request); } httpResponse.Close(); Logger.GetLogger(request.Elect).Info(request.Uri.ToString() + " response status is " + response.StatusCode.ToString()); return(response); } catch (Exception ex) { var r = new Response(); r.StatusCode = HttpStatusCode.BadRequest; r.Data = "response error " + ex.Message; return(r); } }
/// <summary>Called when [decoding a frame].</summary> /// <param name="frame">The frame.</param> protected virtual void OnDecoding(AudioFrame frame) { Decoding?.Invoke(this, new AudioFrameEventArgs(frame)); }
public static void testing_decode(String r, String expected) { String actual = Decoding.Decode(r); Assert.AreEqual(expected, actual); }
private void U8Decoding() { Result.Value = Decoding.Utf8DecordString(Input.Value); }
private void B64Decoding() { Result.Value = Decoding.Base64DecordString(Input.Value); }