Exemplo n.º 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>
        /// Clones this category collection
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            XmlConfigurationCategoryCollection clone = new XmlConfigurationCategoryCollection();

            clone.ResetBeforeEdit();
            clone.ResetChanged();
            clone.ResetAfterEdit();
            clone.ResetEditCancelled();
            clone.Parent = _parent;

            foreach (XmlConfigurationCategory category in base.InnerList)
            {
                XmlConfigurationCategory clonedCategory = (XmlConfigurationCategory)category.Clone();
                clonedCategory.Parent = clone;
                clone.Add(clonedCategory);
            }

            return(clone);
        }
		/// <summary>
		/// Clones this category collection
		/// </summary>
		/// <returns></returns>
		public object Clone()
		{
			XmlConfigurationCategoryCollection clone = new XmlConfigurationCategoryCollection();
			clone.ResetBeforeEdit();
			clone.ResetChanged();
			clone.ResetAfterEdit();
			clone.ResetEditCancelled();
			clone.Parent = _parent;

			foreach(XmlConfigurationCategory category in base.InnerList)
			{
				XmlConfigurationCategory clonedCategory = (XmlConfigurationCategory)category.Clone();				
				clonedCategory.Parent = clone;
				clone.Add(clonedCategory);
			}

			return clone;
		}
		/// <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;
		}