Example #1
0
 private void InitializeNodeGraph()
 {
     if (selectedGraph && selectedGraph.nodes != null)
     {
         selectedOption = null;
     }
 }
Example #2
0
        /// <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);
        }
Example #3
0
 public Node(
     string message,
     NodeOption optionId,
     Action onOptionChosen)
 {
     Message        = message;
     OptionId       = optionId;
     OnOptionChosen = onOptionChosen;
 }
Example #4
0
 protected void OnClickOption(NodeOption option)
 {
     if (selectedOption != null)
     {
         ClearConnectionSelection();
     }
     else
     {
         selectedOption = option;
     }
 }
Example #5
0
        public void ChooseOption(NodeOption option)
        {
            var node = Nodes.SingleOrDefault(x => x.OptionId == option);

            if (node == null)
            {
                //TODO Handle error
                return;
            }

            node.OnOptionChosen();
        }
Example #6
0
        public IHttpMultiClient AddNode(Action <NodeOption> action)
        {
            if (Client != null)
            {
                throw new Exception("Client已初始化,不能再添加节点");
            }

            NodeOption Option = new NodeOption();

            action(Option);
            Option.SetNode();
            return(this);
        }
Example #7
0
 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);
         }
     }
 }
Example #8
0
 /// <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);
 }
Example #9
0
 public void Set(NodeOption opt)
 {
     NodeOption = opt;
 }
Example #10
0
 public HashSet <string> GetSymbols(NodeOption opt)
 {
     return(IsSet(opt) ? new HashSet <string>(NodeOptions[opt].Keys) : new HashSet <string>());
 }
Example #11
0
 public void Clear(NodeOption opt)
 {
     NodeOptions.Remove(opt);
 }
Example #12
0
        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());
        }
Example #13
0
 public bool IsSet(NodeOption opt, string symbol = null)
 {
     return(NodeOptions.ContainsKey(opt) && (symbol == null || NodeOptions[opt].ContainsKey(symbol)));
 }
Example #14
0
 public void QualifyNode(NodeOption option)
 {
     OptionsCombobox.Add(Options[^ 1]);
Example #15
0
 protected void ClearConnectionSelection()
 {
     selectedOption = null;
 }
Example #16
0
 public void CreateConnection(NodeOption option, NODE node)
 {
     option.next = node.id;
     SaveGraph(selectedGraph);
 }
Example #17
0
 public void RemoveConnection(NodeOption option)
 {
     option.next = -1;
     SaveGraph(selectedGraph);
 }
Example #18
0
        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());
        }