示例#1
0
        static void Main(string[] args)
        {
            SCBClient client = new SCBClient("api.scb.se/OV0104");

            SCBNode current = client.TopNode;

            while (true)
            {
                List <SCBNode> nodes = new List <SCBNode>();
                if (current.IsLevel)
                {
                    nodes = client.GetNodesBelow(current);
                    Console.WriteLine($"{0}. Go up");
                    PresentNodes(nodes);
                }
                else if (current.IsTable)
                {
                    SCBMetaData metaData = client.GetMetaData(current.path);
                    PresentMetaData(metaData);

                    bool newQuery = true;

                    while (newQuery)
                    {
                        QueryTable(metaData, client, current);
                        Console.Out.Write("New query? [Y/N] ");
                        string ans = Console.In.ReadLine();
                        newQuery = ans.ToLower().Equals("y");
                    }
                    Console.WriteLine($"{0}. Go up");
                }

                bool isNumber = false;
                int  index    = 0;
                while (!isNumber)
                {
                    Console.Out.Write("Select an item: ");
                    string selection = Console.In.ReadLine();
                    isNumber = int.TryParse(selection, out index);
                }

                if (index == 0)
                {
                    if (!current.path.Equals(client.TopNode.path))
                    {
                        current.path = current.ParentPath();
                        current.type = "l";
                    }
                }
                else
                {
                    SCBNode selectedNode = nodes[index - 1];
                    if (selectedNode != null)
                    {
                        current = selectedNode;
                    }
                }
            }
        }