Пример #1
0
        /// <summary>
        /// Reads an XmlConfigurationCategoryCollection using the specified XPathNavigator
        /// </summary>
        /// <param name="navigator"></param>
        /// <returns></returns>
        private XmlConfigurationCategoryCollection ReadCategories(XPathNavigator navigator, XmlConfigurationCategoryCollection categories)
        {
            if (navigator.HasChildren)
            {
                if (navigator.MoveToFirstChild())
                {
                    // is this element a category node?
                    if (string.Compare(navigator.Name, @"Category", true) == 0)
                    {
                        // so read it
                        XmlConfigurationCategory category = new XmlConfigurationCategory();
                        category.BeginInit();
                        category.Parent = categories;

                        this.ReadCategory(navigator, category);

                        // and add it to the current collection of categories
                        categories.Add(category);
                        category.EndInit();
                    }
                }
            }

            while (navigator.MoveToNext())
            {
                // is this element a category node?
                if (string.Compare(navigator.Name, @"Category", true) == 0)
                {
                    // so read it
                    XmlConfigurationCategory category = new XmlConfigurationCategory();
                    category.BeginInit();
                    category.Parent = categories;

                    this.ReadCategory(navigator, category);

                    // and add it to the current collection of categories
                    categories.Add(category);
                    category.EndInit();
                }
            }

            return(categories);
        }
		/// <summary>
		/// Reads an XmlConfigurationCategoryCollection using the specified XPathNavigator
		/// </summary>
		/// <param name="navigator"></param>
		/// <returns></returns>
		private XmlConfigurationCategoryCollection ReadCategories(XPathNavigator navigator, XmlConfigurationCategoryCollection categories)
		{			
			if (navigator.HasChildren)
			{
				if (navigator.MoveToFirstChild())
				{
					// is this element a category node?
					if (string.Compare(navigator.Name, @"Category", true) == 0)
					{
						// so read it
						XmlConfigurationCategory category = new XmlConfigurationCategory();
						category.BeginInit();
						category.Parent = categories;
						
						this.ReadCategory(navigator, category);						
						
						// and add it to the current collection of categories
						categories.Add(category);
						category.EndInit();
					}					
				}
			}

			while (navigator.MoveToNext())
			{	
				// is this element a category node?
				if (string.Compare(navigator.Name, @"Category", true) == 0)
				{
					// so read it
					XmlConfigurationCategory category = new XmlConfigurationCategory();
					category.BeginInit();
					category.Parent = categories;
					
					this.ReadCategory(navigator, category);					

					// and add it to the current collection of categories
					categories.Add(category);
					category.EndInit();
				}
			}
			
			return categories;
		}