Пример #1
0
 internal void TraceCategories(XmlConfigurationCategoryCollection categories)
 {
     System.Diagnostics.Trace.WriteLine(categories.Fullpath);
     foreach (XmlConfigurationCategory category in categories)
     {
         this.TraceCategories(category.Categories);
     }
 }
 public XmlConfigurationOptionCollectionTypeDescriptor(XmlConfigurationCategoryCollection categories) : this()
 {
     foreach (XmlConfigurationCategory category in categories)
     {
         try
         {
             this.LoadOptions(category.Options);
         }
         catch (System.Exception systemException)
         {
             System.Diagnostics.Trace.WriteLine(systemException);
         }
     }
 }
		public XmlConfigurationOptionCollectionTypeDescriptor(XmlConfigurationCategoryCollection categories) : this()
		{
			foreach(XmlConfigurationCategory category in categories)
			{
				try
				{
					this.LoadOptions(category.Options);
				}
				catch(System.Exception systemException)
				{
					System.Diagnostics.Trace.WriteLine(systemException);
				}
			}
		}
 /// <summary>
 /// Writes a collection of categories to the XmlDocument
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="parent"></param>
 /// <param name="categories"></param>
 /// <param name="alwaysPersist"></param>
 private void WriteCategories(XmlDocument doc, XmlElement parent, XmlConfigurationCategoryCollection categories, bool alwaysPersist)
 {
     try
     {
         /// write each category in this category collection
         foreach (XmlConfigurationCategory category in categories)
         {
             this.WriteCategory(doc, parent, category, alwaysPersist);
         }
     }
     catch (System.Exception systemException)
     {
         System.Diagnostics.Trace.WriteLine(systemException);
     }
 }
Пример #5
0
        /// <summary>
        /// Recursively adds nodes for the specified categories
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="nodes"></param>
        /// <param name="categories"></param>
        private void AddNodesForCategories(TreeView tree, TreeNodeCollection nodes, XmlConfigurationCategoryCollection categories)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new AddNodesForCategoriesInvoker(this.AddNodesForCategories), new object[] { tree, nodes, categories });
                return;
            }

            tree.BeginUpdate();
            try
            {
                foreach (XmlConfigurationCategory category in categories)
                {
                    if (!category.Hidden)
                    {
                        // try and find an existing node that we can merge with
                        CategoryTreeNode n = this.FindNodeForCategory(nodes, category);

                        if (n == null)
                        {
                            n = this.AddNodeForCategory(tree, nodes, category);
                        }

                        if (n != null)
                        {
                            if (!n.IsBoundToCategory(category))
                            {
                                n.BindToCategory(category);
                            }

                            this.AddNodesForCategories(tree, n.Nodes, category.Categories);
                        }
                    }
                }
            }
            catch (System.Exception systemException)
            {
                System.Diagnostics.Trace.WriteLine(systemException);
            }
            finally
            {
                tree.EndUpdate();
            }
        }
Пример #6
0
        /// <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);
        }
Пример #7
0
        public bool ApplyToSelf(ISupportsEditing editableObject, SupportedEditingActions actions)
        {
            XmlConfigurationCategoryCollection categories = editableObject as XmlConfigurationCategoryCollection;

            if (categories != null)
            {
                foreach (XmlConfigurationCategory category in categories)
                {
                    XmlConfigurationCategory myCategory = this[category.ElementName];
                    if (myCategory != null)
                    {
                        try
                        {
                            myCategory.ApplyToSelf((ISupportsEditing)category, actions);
                        }
                        catch (System.Exception systemException)
                        {
                            System.Diagnostics.Trace.WriteLine(systemException);
                        }
                    }
                }
            }
            return(true);
        }
		/// <summary>
		/// Recursively adds nodes for the specified categories
		/// </summary>
		/// <param name="tree"></param>
		/// <param name="nodes"></param>
		/// <param name="categories"></param>
		private void AddNodesForCategories(TreeView tree, TreeNodeCollection nodes, XmlConfigurationCategoryCollection categories)
		{			
			if (this.InvokeRequired)
			{
				this.Invoke(new AddNodesForCategoriesInvoker(this.AddNodesForCategories), new object[] {tree, nodes, categories});
				return;
			}

			tree.BeginUpdate();
			try
			{
				foreach(XmlConfigurationCategory category in categories)
				{					
					if (!category.Hidden)
					{
						// try and find an existing node that we can merge with
						CategoryTreeNode n = this.FindNodeForCategory(nodes, category);												
						
						if (n == null)
							n = this.AddNodeForCategory(tree, nodes, category);
												
						if (n != null)
						{
							if (!n.IsBoundToCategory(category))
								n.BindToCategory(category);

							this.AddNodesForCategories(tree, n.Nodes, category.Categories);						
						}
					}
				}
			}
			catch(System.Exception systemException)
			{
				System.Diagnostics.Trace.WriteLine(systemException);
			}
			finally
			{
				tree.EndUpdate();
			}
		}
		/// <summary>
		/// Writes a collection of categories to the XmlDocument
		/// </summary>
		/// <param name="doc"></param>
		/// <param name="parent"></param>
		/// <param name="categories"></param>
		/// <param name="alwaysPersist"></param>
		private void WriteCategories(XmlDocument doc, XmlElement parent, XmlConfigurationCategoryCollection categories, bool alwaysPersist)
		{
			try
			{				
				/// write each category in this category collection
				foreach(XmlConfigurationCategory category in categories)
					this.WriteCategory(doc, parent, category, alwaysPersist);
			}
			catch(System.Exception systemException)
			{
				System.Diagnostics.Trace.WriteLine(systemException);
			}
		}
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the XmlConfigurationOption class
 /// </summary>
 /// <param name="option">The option to base this option on</param>
 public XmlConfiguration(XmlConfiguration configuration) : base((XmlConfigurationElement)configuration)
 {
     _path       = configuration.Path;
     _categories = configuration.Categories;
 }
		/// <summary>
		/// Initializes a new instance of the XmlConfigurationOption class
		/// </summary>
		/// <param name="option">The option to base this option on</param>
		public XmlConfiguration(XmlConfiguration configuration) : base((XmlConfigurationElement)configuration)
		{
			_path = configuration.Path;
			_categories = configuration.Categories;			
		}
Пример #12
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);
        }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the XmlConfigurationCategory class
 /// </summary>
 public XmlConfigurationCategory(XmlConfigurationCategory category) : base((XmlConfigurationElement)category)
 {
     _options    = category.Options;
     _categories = category.Categories;
     _parent     = category.Parent;
 }
		/// <summary>
		/// Initializes a new instance of the XmlConfigurationCategory class
		/// </summary>
		public XmlConfigurationCategory(XmlConfigurationCategory category) : base((XmlConfigurationElement)category)
		{
			_options = category.Options;
			_categories = category.Categories;
			_parent = category.Parent;
		}
		/// <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;
		}
		internal void TraceCategories(XmlConfigurationCategoryCollection categories)
		{
			System.Diagnostics.Trace.WriteLine(categories.Fullpath);
			foreach(XmlConfigurationCategory category in categories)
				this.TraceCategories(category.Categories);
		}