/// <summary> /// 启动 /// </summary> public void StartUp() { Asyn.Exec(() => { Syn.Wait(() => DateTime.Now >= this.StartTime); if (!this.HasShutDown) { this.Exec(); } Asyn.Exec(() => { Syn.Wait(() => { if (this.HasShutDown) { return(true); } else { if (DateTime.Now - this.Last >= this.Interval) { this.Exec(); } return(false); } }); }); }); }
public static bool Evaluate(string filename) { bool result = false; if (System.IO.File.Exists(filename)) { StreamReader source = null; try { source = System.IO.File.OpenText(filename); Syn analizer = new Syn(source); VCN64Config.File config = analizer.Run(); Console.WriteLine("The file \"" + filename + "\" is valid!"); result = true; } catch (Exception e) { Console.WriteLine("The file \"" + filename + "\" is invalid.\n" + e.Message); } finally { if (source != null) { source.Close(); } } } else { Console.WriteLine("The file \"" + filename + "\" not exists."); } return(result); }
public Socket(System.Net.IPAddress address, int port) { this.OnConnect += () => { }; this.OnData += data => { }; this.OnError += error => { }; this.OnEnd += () => { }; this.sending = false; this.endpoint = new System.Net.IPEndPoint(address, port); this.socket = Reactor.Udp.Socket.Create(); this.socket.Bind(System.Net.IPAddress.Any, 0); this.socket.OnMessage += (remote, data) => { if (remote.ToString() == this.endpoint.ToString()) { this.Receive(data); } }; var syn = new Syn(Random.Get()); this.socket.Send(this.endpoint, syn.Serialize()); }
public string CreateEncodedSyn() { ISyn syn = new Syn() { Encrypted = false, PublicKey = _accountService.PublicKey, NetworkAddress = _session.Open(), Id = _id }; _tokenCryptoService.Sign(syn, _accountService.GetPrivateKeyAsByteArray()); return(syn.GetEncodedToken()); }
public override void Setup() { base.Setup(); _session = new AblySession(new EventHandler <string>((sender, e) => ProcessEncodedAck(e)), "123"); _payload.Add("netAddr", _session.Open()); _token = new Syn() { Encrypted = Boolean.Parse(_header["encrypted"]), PublicKey = _header["pubkey"], NetworkAddress = _payload["netAddr"], Id = _id }; }
public void Compile(string sourcecode) { CodeModifySource = string.Empty; DateTime date = DateTime.Now; var graph = Lex.Analysis(sourcecode); Utils.SaveTime("Lex", date); date = DateTime.Now; var paths = graph.AllPaths(Norm).OrderByDescending(p => p.Cost); Utils.SaveTime("GetPaths", date); date = DateTime.Now; for (int i = 0; i < paths.Count() && i < 3; i++) { var symbols = GetSymbols(paths.ElementAt(i)); var pertinenceSyn = Syn.Validate(symbols); if (pertinenceSyn > 0) { FixSyntatic = new FixSyn(Syn.GraphsSyntactic[0].Root, Grammar); NodeToTreeContainer nttc = new NodeToTreeContainer(FixSyntatic.NodeResult, NameVars, symbols); CodeModifySource = string.Empty; MountCodeModifySource(FixSyntatic.NodeResult); CodeModifySource = CodeModifySource.TrimStart(); Compile(nttc); PertinenceLex = paths.ElementAt(i).Cost; PertinenceSyn = pertinenceSyn; PertinenceTotal = Norm.Calculate(PertinenceLex, PertinenceSyn); break; } } Utils.SaveTime("ValidateSyn", date); GC.Collect(); if (OnCompile != null) { OnCompile(this); } }
public static void WriteSynonyms() { string db_path = @"C:\Users\Administrator\Documents\stackoverflow\FINAL_DATA"; Db db_syns = new Db(db_path); var path = @"clean.txt"; var lines = File.ReadAllLines(path).Where(f => !string.IsNullOrEmpty(f)).ToList(); foreach (var line in lines) { var parts = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var syn = new Syn() { Name = parts[0], Synonyms = parts.Skip(1).Select(f => f).Distinct().Aggregate((a, b) => a + "|" + b) }; db_syns.Table <Syn>().Save(syn); } db_syns.Dispose(); }
public async Task ProcessSyn(string synString) { HandshakeTokenFactory <Syn> synFactory = new HandshakeTokenFactory <Syn>(_idFacade); Syn syn = await synFactory.CreateHandshakeTokenAsync(synString); byte[] pubK = Nethereum.Hex.HexConvertors.Extensions.HexByteConvertorExtensions.HexToByteArray(syn.PublicKey); VerifyHandshakeTokenIDOwnership(syn); if (_tokenCryptoService.VerifySignature(syn)) { _syn = syn; Acknowledge(_syn); } else { throw new SignatureDoesntMatchException("The signature was not " + "generated by the given " + "public Key"); } }
private Boolean OnSyntaxStep() { if (Syn.Step()) { return(true); } foreach (var m in Syn.Errors) { Errors.Add(Message.Create("{0} {1}".Fmt(m.Message, m.Location), m.Location)); } foreach (var m in Syn.Warnings) { Warns.Add(Message.Create("{0} {1}".Fmt(m.Message, m.Location), m.Location)); } if (!Syn.IsFatalError) { Success = true; } return(false); }
public C(Syn syn) { Sa = syn; }
static void Main(string[] args) { // MemberInfo[] members = typeof(Test2).GetPropertiesAndFields().ToArray(); // string json = JsonConvert.SerializeObject(new Test1 { Md5 = "test".MD5(Encoding.UTF8), Msg = Guid.Empty.ToBase64() }); Test1 test1 = JsonConvert.DeserializeObject <Test1>(json); Assert.IsTrue(test1.Md5 == "test".MD5(Encoding.UTF8)); Assert.IsTrue(test1.Msg == Guid.Empty.ToBase64()); // Uri uri = new Uri("https://item.jd.com/37175085087.html"); Assert.IsTrue(uri.GetExtension() == ".html"); // uri = new Uri("https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1"); Assert.IsTrue(uri.SchemaAndHost() == "https://www.baidu.com"); Assert.IsTrue(uri.GetUri("/test/test.html").OriginalString == "https://www.baidu.com/test/test.html"); Assert.IsTrue(uri.IsInternalLink(uri.GetUri("/test/test.html"))); Assert.IsFalse(uri.IsInternalLink(new Uri("https://cn.bing.com/"))); // Kernel32.AddConsoleCtrlHandler(() => { // }); // RegEdit.UpdateWebBrowserVersion(); // { Asyn.Exec(() => { Tcp.Listen("127.0.0.1", 10601, (stream) => { string request = stream.ReadLine(Encoding.UTF8); Console.WriteLine("request:" + request); stream.Write(request.ToByteArray(Encoding.UTF8)); }); }); } { string response = Tcp.SendLine("127.0.0.1", 10601, "test", Encoding.UTF8); Console.WriteLine("response:" + response); response = Tcp.SendLine("127.0.0.1", 10601, "test", Encoding.UTF8); Console.WriteLine("response:" + response); } // Asyn.Exec(() => { NamedPipe.Server("testPipe", (stream) => { string request = stream.ReadLine(Encoding.UTF8); Console.WriteLine("request:" + request); stream.WriteLine(request, Encoding.UTF8); }); }); { string response = NamedPipe.SendLine("testPipe", "hello", Encoding.UTF8); Console.WriteLine("response:" + response); response = NamedPipe.SendLine("testPipe", "hello", Encoding.UTF8); Console.WriteLine("response:" + response); } // Cmd.Exec("ping bibaoke.com"); // Cmd.Exec("TestForm1.exe"); // { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://265.com"); using (WebResponse response = request.GetResponse()) { using (Stream stream = response.GetResponseStream()) { byte[] data1 = stream.ToByteArray(); string text1 = data1.ToString(Encoding.UTF8); WebClient client = new WebClient(); byte[] data2 = client.DownloadData("http://265.com"); string text2 = data2.ToString(Encoding.UTF8); Assert.IsTrue(data1.Length == data2.Length); } } } // string testString = "test string"; string file = Application.SetupDir.CombinePath(Guid.NewGuid()); file.Write(testString, Encoding.UTF8); Assert.IsTrue(file.ReadString(Encoding.UTF8) == testString); file.DeleteFile(); // Pool pool = new Pool(50); for (int i = 0; i < 100; i++) { pool.Execute(i, j => Console.WriteLine(j)); } pool.Execute(() => Thread.Sleep(1000)); pool.Wait(); // int number1 = "10".ToInt(); string number2String = null; int?number2 = number2String.ToInt(); Assert.IsTrue(number1 == 10); Assert.IsTrue(number2 == null); // byte[] data = "测试字符串".ToByteArray(Encoding.UTF8); Base64 base64 = new Base64(data); HexString hex = new HexString(data); Assert.IsTrue(base64.ToHexString() == hex.ToString()); Assert.IsTrue(base64 == hex.ToBase64()); // Assert.IsTrue(new Uri("http://bibaoke.com/post/74").GetUri("71") == new Uri("http://bibaoke.com/post/71")); Assert.IsTrue(new Uri("http://bibaoke.com/post/74").GetUri("/post/71") == new Uri("http://bibaoke.com/post/71")); Assert.IsTrue(new Uri("http://bibaoke.com").GetUri("post/71") == new Uri("http://bibaoke.com/post/71")); // Assert.IsTrue(new Uri("http://bibaoke.com/icon").SetQuery("char=和") == new Uri("http://bibaoke.com/icon?char=和")); Assert.IsTrue( new Uri("http://bibaoke.com/icon?char=和").SetQuery("color=white") == new Uri("http://bibaoke.com/icon?char=和&color=white")); // Assert.IsTrue(new Uri("http://jianzhimao.com.com").GetDomain() == "com.com"); Assert.IsTrue(new Uri("http://pconline.com.cn").GetDomain() == "pconline.com.cn"); // Assert.IsTrue(2.Pow(3) == 8); // Assert.IsTrue("نیک تم | قالب وردپرس, قالب اورجينال فارسي و قالب وردپرس شرکتی".HasUnicode()); // Encoding gbk = MyEncoding.GBK; // Assert.IsTrue("".SplitByWhiteSpace().Length == 0); Assert.IsTrue(" ".SplitByWhiteSpace().Length == 0); Assert.IsTrue(" test1 test2 ".SplitByWhiteSpace()[1] == "test2"); // Assert.IsTrue(new int[] { 1, 2 }.ExtArray(new int[0]).Length == 2); // Assert.IsTrue("test".Repeat(2) == "testtest"); // int[] testArray = new int[100]; 100.Each(index => testArray[index] = index); IEnumerable <int> enumerator = testArray.GetEnumerator(50); int count = 0; enumerator.Each((index, item) => { Assert.IsTrue(item == index + 50); count++; }); Assert.IsTrue(count == 50); // Assert.IsTrue("abcd".SubstringUnsafe(1, 2) == "bc"); Assert.IsTrue("".SubstringUnsafe(0) == ""); // file = Application.SetupDir.CombinePath("testReadBytes.txt"); Assert.IsTrue(file.ReadString(Encoding.UTF8, true) == "abc"); file.Write("abcd", Encoding.UTF8); Assert.IsTrue(file.ReadString(Encoding.UTF8, true) == "abcd"); // Regex pattern = @"(?<order>order\s+by\s+.*?)\s*$".ToRegex( RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase); Assert.IsTrue( pattern.Match("select * from user order by dept desc, id asc").GetValue("order") == "order by dept desc, id asc"); Assert.IsTrue( pattern.Match("select * from user order by id ").GetValue("order") == "order by id"); // Assert.IsTrue("90".IsInt()); Assert.IsTrue("-90".IsInt()); Assert.IsTrue("0".IsInt()); Assert.IsTrue("-9".IsInt()); Assert.IsTrue("-19".IsInt()); Assert.IsTrue("09".IsInt()); Assert.IsTrue("9".IsInt()); Assert.IsFalse("1.9".IsInt()); Assert.IsTrue(" 19".IsInt()); Assert.IsTrue("19".IsInt()); Assert.IsTrue("19 ".IsInt()); Assert.IsFalse("1九".IsInt()); // Assert.IsTrue("192.168.1.1".IsIpv4()); Assert.IsFalse("192.168.1".IsIpv4()); // Agent agent = new Agent("ping vaiying.com -t", AgentMode.Restart, TimeSpan.FromSeconds(2)); agent.StartUp(); Thread.Sleep(3000); agent.ShutDown(); // DateTime startTime = DateTime.Now.AddSeconds(2); Agent notepad = new Agent("notepad", AgentMode.Singleton, startTime.Hour, startTime.Minute, startTime.Second); notepad.StartUp(); Thread.Sleep(1000); notepad.ShutDown(); // long l = 10; Assert.IsTrue(l.ToInt() == 10); l = int.MinValue; Assert.IsTrue(l.ToInt() == int.MinValue); // Syn.Wait(() => { 100.Each((index) => { Console.WriteLine(index); Thread.Sleep(10); }); return(true); }); // try { Syn.Wait(TimeSpan.FromSeconds(1), () => { return(false); }); } catch (TimeoutException ex) { Console.WriteLine(ex.Message); } // Process.GetCurrentProcess().Kill(); }
internal void ReceiveSyn(Syn syn) { var synack = new SynAck(Random.Get(), syn.SequenceNumber + 1); this.socket.Send(this.endpoint, synack.Serialize()); }
public Template(Syn syn) { Sa = syn; }
public L(Syn syn) { Sa = syn; }
public S(Syn syn) { Sa = syn; }