/// <summary>
        /// To the XML.
        /// </summary>
        /// <param name="baseElement">The base element.</param>
        /// <param name="AddCommonAttributes">if set to <c>true</c> [add common attributes].</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override XElement ToXml(XElement baseElement, bool AddCommonAttributes)
        {
            baseElement.SetAttributeValue("name", this.Name);
            baseElement.SetAttributeValue("description", this.Description);

            baseElement.SetAttributeValue("iconUrl", this.IconUrl);

            XElement designerAttributesElement = baseElement.Element("designerAttributes");

            if (designerAttributesElement == null)
            {
                designerAttributesElement = new XElement("designerAttributes");
                baseElement.Add(designerAttributesElement);
            }
            foreach (string key in this.DesignerAttributes.Keys)
            {
                XElement designerAttributeElement = designerAttributesElement.Elements().FirstOrDefault(e => e.Attribute("name") != null && e.Attribute("name").Value == key);
                if (designerAttributeElement == null)
                {
                    designerAttributeElement = new XElement("designerAttribute");
                    designerAttributesElement.Add(designerAttributeElement);
                }
                designerAttributeElement.SetAttributeValue("name", key);
                designerAttributeElement.SetAttributeValue("value", this.DesignerAttributes[key]);
            }


            XElement AttributeCategoriesElement = baseElement.Element("AttributeCategories");

            if (AttributeCategoriesElement == null)
            {
                AttributeCategoriesElement = new XElement("AttributeCategories");
                baseElement.Add(AttributeCategoriesElement);
            }
            foreach (AttributeCategoryModel item in this.AttributeCategories)
            {
                XElement categoryElement = AttributeCategoriesElement.Elements().FirstOrDefault(e => e.Attribute("name") != null && e.Attribute("name").Value == item.Name);
                if (categoryElement != null)
                {
                    item.ToXml(categoryElement, true);
                }
                else
                {
                    AttributeCategoriesElement.Add(item.ToXml());
                }
            }

            return(baseElement);
        }
        /// <summary>
        /// To the XML.
        /// </summary>
        /// <param name="baseElement">The base element.</param>
        /// <param name="AddCommonAttributes">if set to <c>true</c> [add common attributes].</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override XElement ToXml(XElement baseElement, bool AddCommonAttributes)
        {
            baseElement.SetAttributeValue("name", this.Name);
            baseElement.SetAttributeValue("description", this.Description);

            baseElement.SetAttributeValue("iconUrl", this.IconUrl);
            baseElement.SetAttributeValue("containerType", this.ContainerType);
            baseElement.SetAttributeValue("class", this.DefaultStyleClass);

            if (!this.ContainerType.Equals("none", StringComparison.OrdinalIgnoreCase))
            {
                if (!string.IsNullOrEmpty(this.ContainerPropertyTypes))
                {
                    baseElement.SetAttributeValue("containerType", this.ContainerPropertyTypes);
                }
                if (!string.IsNullOrEmpty(this.ContainerProperty))
                {
                    baseElement.SetAttributeValue("containerType", this.ContainerProperty);
                }
            }

            baseElement.SetAttributeValue("browsable", this.Browsable);

            XElement designerAttributesElement = baseElement.Element("designerAttributes");

            if (designerAttributesElement == null)
            {
                designerAttributesElement = new XElement("designerAttributes");
                baseElement.Add(designerAttributesElement);
            }
            foreach (string key in this.DesignerAttributes.Keys)
            {
                XElement designerAttributeElement = designerAttributesElement.Elements().FirstOrDefault(e => e.Attribute("name") != null && e.Attribute("name").Value == key);
                if (designerAttributeElement == null)
                {
                    designerAttributeElement = new XElement("designerAttribute");
                    designerAttributesElement.Add(designerAttributeElement);
                }
                designerAttributeElement.SetAttributeValue("name", key);
                designerAttributeElement.SetAttributeValue("value", this.DesignerAttributes[key]);
            }


            XElement AttributeCategoriesElement = baseElement.Element("AttributeCategories");

            if (AttributeCategoriesElement == null)
            {
                AttributeCategoriesElement = new XElement("AttributeCategories");
                baseElement.Add(AttributeCategoriesElement);
            }
            foreach (AttributeCategoryModel item in this.AttributeCategories)
            {
                XElement categoryElement = AttributeCategoriesElement.Elements().FirstOrDefault(e => e.Attribute("name") != null && e.Attribute("name").Value == item.Name);
                if (categoryElement != null)
                {
                    item.ToXml(categoryElement, true);
                }
                else
                {
                    AttributeCategoriesElement.Add(item.ToXml());
                }
            }

            XElement VisualStatesDefinitionsElement = baseElement.Element("VisualStates");

            if (VisualStatesDefinitionsElement == null)
            {
                VisualStatesDefinitionsElement = new XElement("VisualStates");
                baseElement.Add(VisualStatesDefinitionsElement);
            }
            foreach (VisualStateDefinitionModel item in this.VisualStates)
            {
                XElement VisualStateDefinitionElement = VisualStatesDefinitionsElement.Elements().FirstOrDefault(e => e.Attribute("name") != null && e.Attribute("name").Value == item.Name);
                if (VisualStateDefinitionElement != null)
                {
                    item.ToXml(VisualStateDefinitionElement, true);
                }
                else
                {
                    AttributeCategoriesElement.Add(item.ToXml());
                }
            }

            return(baseElement);
        }