Esempio n. 1
0
        private void AddDemo(ToolStripMenuItem parentMenuItem, DemoDefinition demoDefinition)
        {
            var menuItem = new ToolStripMenuItem();

            menuItem.Size   = new Size(152, 22);
            menuItem.Text   = demoDefinition.Title;
            menuItem.Click += MenuItem_Click;
            menuItem.Tag    = demoDefinition;
            parentMenuItem.DropDownItems.Add(menuItem);
        }
Esempio n. 2
0
        private void DisplayDefinition(DemoDefinition demo)
        {
            this.txtURL.Text   = demo.URL;
            this.cbMethod.Text = demo.Method;

            if (demo.URL.Contains("_bulk"))
            {
                this.txtCommand.Text = demo.Content;
            }
            else
            {
                this.txtCommand.Text = PrettyPrintJSON(demo.Content);
            }

            this.txtResult.Text = "";
            this.lblTitle.Text  = "  Demo - " + demo.Title;
        }
Esempio n. 3
0
        private void SetupMenus()
        {
            var defaultDefinition = default(DemoDefinition);

            foreach (var file in Directory.GetFiles("demos", "*.txt"))
            {
                var category = AddDemoCategory(Path.GetFileNameWithoutExtension(file));

                using (var contents = File.OpenText(file))
                {
                    var line = "";
                    while ((line = contents.ReadLine()) != null)
                    {
                        var title = line;
                        line = contents.ReadLine();
                        var method = line.Split(' ')[0];
                        var url    = line.Split(new char[] { ' ', '\t' })[1];

                        var payload = "";
                        if (method.StartsWith("PUT") || method.StartsWith("POST"))
                        {
                            while ((line = contents.ReadLine()) != null && !string.IsNullOrWhiteSpace(line))
                            {
                                payload += line + System.Environment.NewLine;
                            }
                        }

                        if (method.StartsWith("GET") || method.StartsWith("DELETE"))
                        {
                            SkipBlankLine(contents);
                        }


                        defaultDefinition = new DemoDefinition()
                        {
                            Title = title, Method = method, URL = url, Content = payload
                        };
                        AddDemo(category, defaultDefinition);
                    }
                }
            }



            DisplayDefinition(defaultDefinition);
        }