Ejemplo n.º 1
0
        //Get all the urls associated with the selected category
        private void PopulateURL()
        {
            //there may be something in there already from a previous selection
            URLComboBox.Items.Clear();
            URLComboBox.Text = "";
            MethodComboBox.Items.Clear();
            MethodComboBox.Text = "";
            ClearParameters();
            IDTextBox.Enabled = false;

            //find by selected
            currentSelectedObject = apiElementsList.Find(FindByCategory);

            if (currentSelectedObject != null)
            {
                //hold all the urls possible for this category
                List <string> urls = currentSelectedObject.urlClass.URLS;

                if (urls != null && urls.Count > 0)
                {
                    foreach (string s in urls)
                    {
                        URLComboBox.Items.Add(s);
                    }
                }
            }
        }
        //quick and dirty
        public List<ApiXmlObject> ReadConfigFile()
        {
            try
            {
                xmlDoc.Load(xmlFileName);

                //First grab all the types of contexts child nodes
                XmlNodeList contextNodeList = xmlDoc.GetElementsByTagName("context");
                XmlNodeList contextChildNodesList = null;
                XmlNodeList itemsNodeList = null;
                XmlNodeList innerItemsNodeList = null;
                XmlAttributeCollection innerItemsAttributes = null;
                ApiXmlObject tempHolder = null;

                //there should only be one
                foreach (XmlNode node in contextNodeList)
                {
                    contextChildNodesList = node.ChildNodes;
                }

                //now go through all of the children
                string urlBase; //this is part of the url
                foreach (XmlNode node in contextChildNodesList)
                {
                    urlBase = "/" + node.Name;

                    itemsNodeList = node.ChildNodes;
                    //go through all the item nodes
                    //each item node is an object in our list
                    foreach (XmlNode itemNode in itemsNodeList)
                    {
                        //inner items are <name> and <url>
                        innerItemsNodeList = itemNode.ChildNodes;
                        tempHolder = new ApiXmlObject();
                        foreach (XmlNode innerItemNode in innerItemsNodeList)
                        {
                            if (innerItemNode.Name == "name")
                            {
                                tempHolder.Category = innerItemNode.InnerText;
                            }
                                //url has attributes as well as inner text
                            else if (innerItemNode.Name == "URL")
                            {
                                //set the url
                                tempHolder.urlClass.URLS.Add(urlBase + innerItemNode.InnerText);

                                //methods and parameters are attributes
                                innerItemsAttributes = innerItemNode.Attributes;
                                if (innerItemsAttributes.Count > 0)
                                {
                                    foreach (XmlAttribute att in innerItemsAttributes)
                                    {
                                        //add even if blank so the size of the collections are always the same
                                        if (att.Name == "Methods")
                                        {
                                            tempHolder.urlClass.HttpMethods.Add(att.Value);
                                        }
                                        else if (att.Name == "Parameters")
                                        {
                                            tempHolder.urlClass.Parameters.Add(att.Value);
                                        }
                                    }
                                }
                            }
                        }

                        //add the item to the full list
                        resultList.Add(tempHolder);
                    }

                }

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return resultList;
        }
Ejemplo n.º 3
0
        //Get all the urls associated with the selected category
        private void PopulateURL()
        {
            //there may be something in there already from a previous selection
            URLComboBox.Items.Clear();
            URLComboBox.Text = "";
            MethodComboBox.Items.Clear();
            MethodComboBox.Text = "";
            ClearParameters();
            IDTextBox.Enabled = false;

            //find by selected
            currentSelectedObject = apiElementsList.Find(FindByCategory);

            if (currentSelectedObject != null)
            {
                //hold all the urls possible for this category
                List<string> urls = currentSelectedObject.urlClass.URLS;

                if (urls != null && urls.Count > 0)
                {
                    foreach (string s in urls)
                    {
                        URLComboBox.Items.Add(s);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 // Explicit predicate delegate to determine if this current selected item is equal
 // to in the list
 private bool FindByCategory(ApiXmlObject obj)
 {
     string selectedItem = CategoryComboBox.SelectedItem.ToString();
     return (obj.Category == selectedItem);
 }
Ejemplo n.º 5
0
        //quick and dirty
        public List <ApiXmlObject> ReadConfigFile()
        {
            try
            {
                xmlDoc.Load(xmlFileName);

                //First grab all the types of contexts child nodes
                XmlNodeList            contextNodeList       = xmlDoc.GetElementsByTagName("context");
                XmlNodeList            contextChildNodesList = null;
                XmlNodeList            itemsNodeList         = null;
                XmlNodeList            innerItemsNodeList    = null;
                XmlAttributeCollection innerItemsAttributes  = null;
                ApiXmlObject           tempHolder            = null;

                //there should only be one
                foreach (XmlNode node in contextNodeList)
                {
                    contextChildNodesList = node.ChildNodes;
                }

                //now go through all of the children
                string urlBase; //this is part of the url
                foreach (XmlNode node in contextChildNodesList)
                {
                    urlBase = "/" + node.Name;

                    itemsNodeList = node.ChildNodes;
                    //go through all the item nodes
                    //each item node is an object in our list
                    foreach (XmlNode itemNode in itemsNodeList)
                    {
                        //inner items are <name> and <url>
                        innerItemsNodeList = itemNode.ChildNodes;
                        tempHolder         = new ApiXmlObject();
                        foreach (XmlNode innerItemNode in innerItemsNodeList)
                        {
                            if (innerItemNode.Name == "name")
                            {
                                tempHolder.Category = innerItemNode.InnerText;
                            }
                            //url has attributes as well as inner text
                            else if (innerItemNode.Name == "URL")
                            {
                                //set the url
                                tempHolder.urlClass.URLS.Add(urlBase + innerItemNode.InnerText);

                                //methods and parameters are attributes
                                innerItemsAttributes = innerItemNode.Attributes;
                                if (innerItemsAttributes.Count > 0)
                                {
                                    foreach (XmlAttribute att in innerItemsAttributes)
                                    {
                                        //add even if blank so the size of the collections are always the same
                                        if (att.Name == "Methods")
                                        {
                                            tempHolder.urlClass.HttpMethods.Add(att.Value);
                                        }
                                        else if (att.Name == "Parameters")
                                        {
                                            tempHolder.urlClass.Parameters.Add(att.Value);
                                        }
                                    }
                                }
                            }
                        }

                        //add the item to the full list
                        resultList.Add(tempHolder);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return(resultList);
        }
Ejemplo n.º 6
0
        // Explicit predicate delegate to determine if this current selected item is equal
        // to in the list
        private bool FindByCategory(ApiXmlObject obj)
        {
            string selectedItem = CategoryComboBox.SelectedItem.ToString();

            return(obj.Category == selectedItem);
        }