//DCSolver getSolver(); public void AddComponent(List <string> parts, Component c) { c.ComponentID = parts[1]; if (parts.Count >= (c.GetNumberOfPins() + 1)) { for (int i = 0; i < c.GetNumberOfPins(); i++) { string netName = parts[i + 2]; Net net = new Net(); bool foundNet = false; foreach (var a in Nets) { if (a.NetName == netName) { net = a; foundNet = true; break; } } if (!foundNet) { net = new Net(); net.NetName = netName; Nets.Add(net); } c.PinConnections.Add(net); NetConnection conn = new NetConnection(); conn.component = c; conn.pin = i; net.connections.Add(conn); } } c.SetParameters(new ParameterSet(parts)); Components.Add(c); }
void onConnectAccountSucess() { Cmd.ReqAccountOperation req = new Cmd.ReqAccountOperation(); req.action = Cmd.AccountAction.AccountAction_Login; req.user = user_; req.password = password_; Nets.Send(Cmd.CLIENTID.RQAccountOperation, req); }
void onConnectGameSucess() { Cmd.ReqLoginGameServer req = new Cmd.ReqLoginGameServer(); req.time = preOperation_.time; req.token = preOperation_.token; req.accountid = preOperation_.accountid; Nets.Send(Cmd.CLIENTID.RQLoginGame, req); }
internal override void DoWhenFailed(Nets.ReplyCode code) { codeTextBox.SelectAll(); codeTextBox.Focus(); okButton.Enabled = true; base.DoWhenFailed(code); }
public async Task CreateOrderWithWrongTokens() { var nets = new Nets("foo", "bar", new HttpClientApiCaller(), Endpoints.Test); await Assert.ThrowsAsync <AuthenticationException>(async() => await nets.RegisterAsync("12345", 100, "NOK", new RegisterOptions { RedirectUrl = new Uri("http://localhost/Test") })); }
private void ClearNets() { foreach (var net in Nets) { net.Manager = null; } Nets.Clear(); }
public async Task CreateOrderSuccessFully() { var nets = new Nets(MerchantId, Token, new HttpClientApiCaller(), Endpoints.Test); var transactionId = await nets.RegisterAsync("12345", 100, "NOK", new RegisterOptions { RedirectUrl = new Uri("http://localhost/Test") }); Assert.False(string.IsNullOrEmpty(transactionId)); }
public Address(string encoded) : base(encoded) { if (this.RawKeyLength != 20) { throw new ArgumentException(LengthError); } if (this.Version != Nets.Get <N>().AddressPrefix) { throw new ArgumentException(NetworkMismatch.With(typeof(N).Name)); } }
public WifKey(string encoded) : base(encoded) { if (this.RawKeyLength != 32) { throw new ArgumentException(LengthError); } if (this.Version != Nets.Get <N>().PrivateKeyPrefix) { throw new ArgumentException(NetworkMismatch.With(typeof(N).Name)); } }
public Form1() { InitializeComponent(); label1.Text = "Net"; label2.Text = "Mask"; button1.Text = "Search"; label3.Text = "/"; Nets.Add("192.168.0.1"); Nets.Add("168.95.1.1"); Nets.Add("168.95.128.1"); comboBox1.Items.AddRange(Nets.ToArray()); Masks = Enumerable.Range(24, 32 - 24 + 1).ToList(); foreach (var item in Masks) { comboBox2.Items.Add(item); } using (StreamReader sr = new StreamReader("IP.txt")) { while (!sr.EndOfStream) { ONets.Add(sr.ReadLine()); } } Dictionary <string, int> dic = new Dictionary <string, int>(); dic.Add("A", 0); dic.Add("B", 64); dic.Add("C", 192); foreach (var item in ONets) { string temp = item.Split(',')[0] + ","; temp += dic[item.Split(',')[0]] + "."; var a = item.Split(',')[1].Split('.'); for (int i = 1; i <= 3; i++) { temp += a[i] + "."; } temp = temp.Substring(0, temp.Length - 1) + ","; temp += item.Split(',')[2]; FixNets.Add(temp); } foreach (var item in FixNets) { CleanNets.Add(item.Split(',')[1].Split('.').ToList().ConvertAll <int>(int.Parse).ToList().ToArray()); } comboBox1.SelectedIndex = 0; comboBox2.Text = "24"; button1_Click(null, null); }
public async Task CreateAndQueryOrder() { var nets = new Nets(MerchantId, Token, new HttpClientApiCaller(), Endpoints.Test); var transactionId = await nets.RegisterAsync("12345", 500, "NOK", new RegisterOptions { RedirectUrl = new Uri("http://localhost/Test") }); var data = await nets.QueryAsync(transactionId); Assert.Equal(500, data.OrderInformation.Total); Assert.Equal("NOK", data.OrderInformation.Currency); }
void SendMessage() { if (this.window_.input_.text.Length == 0) { return; } Cmd.ReqChat cmd = new Cmd.ReqChat(); cmd.channel = Cmd.MessageChannel.MessageChannel_User_World; cmd.from = LoginSystem.Instance.currentRole.name; cmd.roleID = LoginSystem.Instance.currentRole.id; cmd.content = this.window_.input_.text; Nets.Send(Cmd.CLIENTID.RQChat, cmd); }
public async Task RegisterTransaction_WhenTransactionIdAlreadyExists_ShouldThrowUniqueTransactionIdException() { var transactionId = DateTime.Now.Ticks; var nets = new Nets(MerchantId, Token, new HttpClientApiCaller(), Endpoints.Test); await nets.RegisterAsync("12345", 500, "NOK", new RegisterOptions { TransactionId = transactionId.ToString(), RedirectUrl = new Uri("http://localhost/Test") }); await Assert.ThrowsAsync <UniqueTransactionIdException>(() => nets.RegisterAsync("12345", 500, "NOK", new RegisterOptions { TransactionId = transactionId.ToString(), RedirectUrl = new Uri("http://localhost/Test") })); }
protected override void OnCommand(EventContext context) { if (context.sender == this.window.enterGame2) { if (LoginSystem.Instance.HasRole()) { Nets.Send(Cmd.CLIENTID.RQEnterGame); this.window.enterGame2.enabled = false; } else { var cmd = new Cmd.ReqCreateRole(); cmd.name = this.window.name1.text; cmd.sex = 0; cmd.job = 1; Nets.Send(Cmd.CLIENTID.RQCreateRole, cmd); } } }
private void AddNet(WaterNet net) { net.Manager = this; Nets.Add(net); }
public Address(IEnumerable <byte> publicKey) : base(Nets.Get <N>().AddressPrefix, publicKey.Sha256().RipeMD160()) { }
public WifKey(IEnumerable <byte> privateKey) : base(Nets.Get <N>().PrivateKeyPrefix, privateKey) { }
public void UpdateWaterNets() { var unNetQueue = ClearWaterNets(); var unNetDiffQueue = new Queue <IBuilding_WaterNet>(); while (unNetQueue.Count > 0) { var thing = unNetQueue.Dequeue(); var inputNets = new List <WaterNet>(); var outputNets = new List <WaterNet>(); if (!thing.IsSameConnector) { unNetDiffQueue.Enqueue(thing); continue; } if (!thing.HasConnector) { UnNetThings.Add(thing); continue; } foreach (var net in Nets) { foreach (var t in net.AllThings) { if (thing.IsOutputTo(t) && !outputNets.Contains(net)) { outputNets.Add(t.InputWaterNet); } if (t.IsOutputTo(thing) && !inputNets.Contains(net)) { inputNets.Add(t.OutputWaterNet); } } } var connectNets = new List <WaterNet>(); connectNets.AddRange(inputNets); foreach (var net in outputNets) { if (!connectNets.Contains(net)) { connectNets.Add(net); } } if (connectNets.Count == 0) { // 0個=新しい水道網 var newNet = new WaterNet(); newNet.AddThing(thing); AddNet(newNet); } else if (connectNets.Count == 1) { // 1個=既存の水道網に加える if (!connectNets[0].AllThings.Contains(thing)) { connectNets[0].AddThing(thing); } } else { // 2個以上=新しい物と、既存の水道網を全て最初の水道網に結合する if (!connectNets[0].AllThings.Contains(thing)) { connectNets[0].AddThing(thing); } for (var i = 1; i < connectNets.Count; i++) { // 消滅する水道網に所属している物を全て移し替える foreach (var t in connectNets[i].AllThings) { if (!connectNets[0].AllThings.Contains(t)) { connectNets[0].AddThing(t); } } // 接続水道網の終えたので水道網を削除 Nets.Remove(connectNets[i]); } } } while (unNetDiffQueue.Count > 0) { var thing = unNetDiffQueue.Dequeue(); var inputNets = new List <WaterNet>(); var outputNets = new List <WaterNet>(); if (!thing.HasConnector) { UnNetThings.Add(thing); continue; } foreach (var net in Nets) { foreach (var t in net.AllThings) { if (thing.IsOutputTo(t) && !outputNets.Contains(net)) { outputNets.Add(t.InputWaterNet); } if (t.IsOutputTo(thing) && !inputNets.Contains(net)) { inputNets.Add(t.OutputWaterNet); } } } if (inputNets.Count == 0) { // 0個=新しい水道網 var newNet = new WaterNet(); newNet.AddInputThing(thing); AddNet(newNet); } else if (inputNets.Count == 1) { // 1個=既存の水道網に加える if (!inputNets[0].AllThings.Contains(thing)) { inputNets[0].AddInputThing(thing); } } else { // 2個以上=新しい物と、既存の水道網を全て最初の水道網に結合する if (!inputNets[0].AllThings.Contains(thing)) { inputNets[0].AddInputThing(thing); } for (var i = 1; i < inputNets.Count; i++) { // 消滅する水道網に所属している物を全て移し替える foreach (var t in inputNets[i].AllThings) { if (!inputNets[0].AllThings.Contains(t)) { inputNets[0].AddInputThing(t); } } // 接続水道網の終えたので水道網を削除 Nets.Remove(inputNets[i]); } } if (outputNets.Count == 0) { // 0個=新しい水道網 var newNet = new WaterNet(); newNet.AddOutputThing(thing); AddNet(newNet); } else if (outputNets.Count == 1) { // 1個=既存の水道網に加える if (!outputNets[0].AllThings.Contains(thing)) { outputNets[0].AddOutputThing(thing); } } else { // 2個以上=新しい物と、既存の水道網を全て最初の水道網に結合する if (!outputNets[0].AllThings.Contains(thing)) { outputNets[0].AddOutputThing(thing); } for (var i = 1; i < outputNets.Count; i++) { // 消滅する水道網に所属している物を全て移し替える foreach (var t in outputNets[i].AllThings) { if (!outputNets[0].AllThings.Contains(t)) { outputNets[0].AddOutputThing(t); } } // 接続水道網の終えたので水道網を削除 Nets.Remove(outputNets[i]); } } } }
public void RemoveNet(WaterNet net) { net.Manager = null; Nets.Remove(net); }
public void ReadNetlist(string data) { var ss1 = data.Split(new[] { '\r', '\n' }); foreach (var line in ss1) { var ss2 = line.Split(new[] { ' ' }); List <string> parts = new List <string>(); foreach (var part in ss2) { parts.Add(part); } if (parts.Count >= 2) { if (parts[0] == "NET") { Net n = new Net(); n.NetName = parts[1]; if (parts.Count >= 3) { n.IsFixedVoltage = true; n.NetVoltage = Convert.ToDouble(parts[2]); } Nets.Add(n); } else if (parts[0] == "RES") { AddComponent(parts, new Resistor()); } else if (parts[0] == "CAP") { AddComponent(parts, new Capacitor()); } else if (parts[0] == "DIODE") { AddComponent(parts, new Diode()); } else if (parts[0] == "BJT") { AddComponent(parts, new BJT()); } else if (parts[0] == "NMOS") { AddComponent(parts, new NMOS()); } else if (parts[0] == "OPAMP") { AddComponent(parts, new Opamp()); } else if (parts[0].StartsWith("LOGIC_")) { AddComponent(parts, new LogicGate(parts[0].Substring(6))); } else { Console.WriteLine("WARNING : Unknown component type " + parts[0]); } } } }
public void InterpretResponseCode(string responseCode, IEnumerable <KeyValuePair <ResponseCodeField, ResponseCodeError> > errors) { var exception = Assert.Throws <InvalidResponseException>(() => Nets.InterpretResponseCode(responseCode)); Assert.Equal(errors, exception.Errors); }