private void InitializeNodeGraph() { if (selectedGraph && selectedGraph.nodes != null) { selectedOption = null; } }
/// <summary> /// 请求 /// </summary> /// <param name="Item"></param> /// <param name="Containers"></param> /// <returns></returns> private string RequestString(NodeOption Item, Action <CookieContainer, Uri> Containers = null) { Stream stream = null; if (Item.ReqType == MultiType.GET) { stream = Client.GetAsync(Item.URI).Result.Content.ReadAsStreamAsync().Result; } else if (Item.ReqType == MultiType.DELETE) { stream = Client.DeleteAsync(Item.URI).Result.Content.ReadAsStreamAsync().Result; } else if (Item.ReqType == MultiType.POST) { stream = Client.PostAsync(Item.URI, Item.Contents).Result.Content.ReadAsStreamAsync().Result; } else { stream = Client.PutAsync(Item.URI, Item.Contents).Result.Content.ReadAsStreamAsync().Result; } if (stream.Length < 0) { return(null); } using StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(Item.Encoding)); string result = reader.ReadToEnd(); Containers?.Invoke(Container, Item.URI); return(result); }
public Node( string message, NodeOption optionId, Action onOptionChosen) { Message = message; OptionId = optionId; OnOptionChosen = onOptionChosen; }
protected void OnClickOption(NodeOption option) { if (selectedOption != null) { ClearConnectionSelection(); } else { selectedOption = option; } }
public void ChooseOption(NodeOption option) { var node = Nodes.SingleOrDefault(x => x.OptionId == option); if (node == null) { //TODO Handle error return; } node.OnOptionChosen(); }
public IHttpMultiClient AddNode(Action <NodeOption> action) { if (Client != null) { throw new Exception("Client已初始化,不能再添加节点"); } NodeOption Option = new NodeOption(); action(Option); Option.SetNode(); return(this); }
public void Set(NodeOption opt, params string[] symbols) { if (!NodeOptions.ContainsKey(opt)) { NodeOptions[opt] = new Dictionary <string, List <dynamic> >(); } foreach (var smb in symbols) { if (!NodeOptions[opt].ContainsKey(smb)) { NodeOptions[opt].Add(smb, null); } } }
/// <summary> /// 请求 /// </summary> /// <param name="Item"></param> /// <param name="Containers"></param> /// <returns></returns> private Byte[] RequestBytes(NodeOption Item, Action <CookieContainer, Uri> Containers = null) { byte[] result = null; if (Item.ReqType == MultiType.GET) { result = Client.GetAsync(Item.URI).Result.Content.ReadAsByteArrayAsync().Result; } else if (Item.ReqType == MultiType.DELETE) { result = Client.DeleteAsync(Item.URI).Result.Content.ReadAsByteArrayAsync().Result; } else if (Item.ReqType == MultiType.POST) { result = Client.PostAsync(Item.URI, Item.Contents).Result.Content.ReadAsByteArrayAsync().Result; } else { result = Client.PutAsync(Item.URI, Item.Contents).Result.Content.ReadAsByteArrayAsync().Result; } Containers?.Invoke(Container, Item.URI); return(result); }
public void Set(NodeOption opt) { NodeOption = opt; }
public HashSet <string> GetSymbols(NodeOption opt) { return(IsSet(opt) ? new HashSet <string>(NodeOptions[opt].Keys) : new HashSet <string>()); }
public void Clear(NodeOption opt) { NodeOptions.Remove(opt); }
private void ProcessHeader() { string type = string.Empty; string fee = string.Empty; string refund = string.Empty; string val = string.Empty; NodeOption option; do { _nodetype = NodeType.None; switch (_reader.NodeType) { case XmlNodeType.Element: switch (_reader.Name.ToUpperInvariant()) { case "TRADES": uint.TryParse(_reader["id"], out _menuid); break; case "TRADE": type = _reader["type"]; fee = _reader["fee"]; refund = _reader["refund"]; if (type != null) { type = type.ToUpperInvariant(); } break; } break; case XmlNodeType.Text: val = _reader.Value; break; case XmlNodeType.EndElement: switch (_reader.Name.ToUpperInvariant()) { case "TRADE": uint menu; option = new NodeOption(); uint.TryParse(val, out menu); uint.TryParse(fee, out option.fee); uint.TryParse(refund, out option.refund); if (type == "SINGLE") { option.node = NodeTypeSpeciafier.Single; } else if (type == "GROUPED") { option.node = NodeTypeSpeciafier.Grouped; } nodeoptions[menu] = option; break; case "TRADES": part = 1; break; } break; } }while (part == 0 && _reader.Read()); }
public bool IsSet(NodeOption opt, string symbol = null) { return(NodeOptions.ContainsKey(opt) && (symbol == null || NodeOptions[opt].ContainsKey(symbol))); }
public void QualifyNode(NodeOption option) { OptionsCombobox.Add(Options[^ 1]);
protected void ClearConnectionSelection() { selectedOption = null; }
public void CreateConnection(NodeOption option, NODE node) { option.next = node.id; SaveGraph(selectedGraph); }
public void RemoveConnection(NodeOption option) { option.next = -1; SaveGraph(selectedGraph); }
private void ProcessHeader() { string type = string.Empty; string fee = string.Empty; string refund = string.Empty; string val = string.Empty; NodeOption option; do { _nodetype = NodeType.None; switch (_reader.NodeType) { case XmlNodeType.Element: switch (_reader.Name.ToUpperInvariant()) { case "TRADES": uint.TryParse(_reader["id"], out _menuid); break; case "TRADE": type = _reader["type"]; fee = _reader["fee"]; refund = _reader["refund"]; if (type != null) type = type.ToUpperInvariant(); break; } break; case XmlNodeType.Text: val = _reader.Value; break; case XmlNodeType.EndElement: switch (_reader.Name.ToUpperInvariant()) { case "TRADE": uint menu; option = new NodeOption(); uint.TryParse(val, out menu); uint.TryParse(fee, out option.fee); uint.TryParse(refund, out option.refund); if (type == "SINGLE") option.node = NodeTypeSpeciafier.Single; else if (type == "GROUPED") option.node = NodeTypeSpeciafier.Grouped; nodeoptions[menu] = option; break; case "TRADES": part = 1; break; } break; } } while (part == 0 && _reader.Read()); }