예제 #1
0
        /// <summary>
        /// 重置所有的属性,包括Id。一般情况下是从外部导入或复制时调用。
        /// </summary>
        public void ResetAllProperty(bool isRemoveContent, bool isHomeType)
        {
            XmlNodeList snipNodes = DocumentElement.SelectNodes("//snip");

            foreach (XmlNode snipNode in snipNodes)
            {
                XmlElement snipEle = (XmlElement)snipNode;
                snipEle.SetAttribute("id", Utility.Guid.NewGuid());
                if (snipEle.GetAttribute("type").ToLower() == PageSnipType.Content.ToString().ToLower())
                {
                    if (isHomeType)
                    {
                        snipEle.SetAttribute("type", PageSnipType.None.ToString());
                        snipEle.SetAttribute("hasSnip", false.ToString());
                        XmlUtilService.RemoveAllChilds(snipEle);
                        continue;
                    }
                    if (isRemoveContent)
                    {
                        XmlUtilService.RemoveAllChilds((XmlElement)snipEle.SelectSingleNode("parts"));
                        continue;
                    }
                }
                XmlNodeList partNodes = snipEle.SelectNodes("//part");
                foreach (XmlNode partNode in partNodes)
                {
                    XmlElement partEle = (XmlElement)partNode;
                    partEle.SetAttribute("partId", XmlUtilService.CreateIncreaseId());
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 由于ChannelElement根据属性type要生成不同的类型,所以不能用AnyXmlElement里的逻辑.
        /// </summary>
        public override XmlNode Clone()
        {
            ChannelSimpleExXmlElement channelEle = Activator.CreateInstance(this.GetType(), this.OwnerDocument)
                                                   as ChannelSimpleExXmlElement;

            XmlUtilService.CopyXmlElement(this, channelEle);
            return(channelEle);
        }
예제 #3
0
        public override XmlNode Clone()
        {
            AnyXmlElement targetEle = OwnerDocument.CreateElement(this.Name)
                                      as AnyXmlElement;

            XmlUtilService.CopyXmlElement(this, targetEle);
            return(targetEle);
        }
예제 #4
0
        /// <summary>
        /// 通过XmlElement的OuterXml返回的字符串生成XmlElement
        /// </summary>
        public XmlElement ParseElement(string outerXml)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(outerXml);

            XmlElement newEle = this.CreateElement(doc.DocumentElement.Name);

            XmlUtilService.CopyXmlElement(doc.DocumentElement, newEle);

            return(newEle);
        }
예제 #5
0
        public string[] GetTreeOpenItems()
        {
            XmlElement treeOpenItems = (XmlElement)this.DocumentElement.SelectSingleNode("treeOpenItems");

            if (treeOpenItems == null)
            {
                treeOpenItems = this.CreateElement("treeOpenItems");
                this.DocumentElement.AppendChild(treeOpenItems);
            }

            return(XmlUtilService.GetGroupItems(treeOpenItems, "item", ItemsDataMode.CData));
        }
예제 #6
0
        public void SetTreeOpenItems(string[] values)
        {
            XmlElement treeOpenItems = (XmlElement)this.DocumentElement.SelectSingleNode("treeOpenItems");

            if (treeOpenItems == null)
            {
                treeOpenItems = this.CreateElement("treeOpenItems");
                this.DocumentElement.AppendChild(treeOpenItems);
            }

            XmlUtilService.SetGroupItems(treeOpenItems, "item", ItemsDataMode.CData, values);
            this.Save();
        }
예제 #7
0
        public override void Save()
        {
            SaveDoc();
            List <AnyXmlElement> channelEles = GetAllChannelElement();

            XmlUtilService.RemoveAllChilds(SdsiteElement);
            foreach (AnyXmlElement ele in channelEles)
            {
                AnyXmlElement cEle = (AnyXmlElement)CreateElement("channelofsnip");
                cEle.SetAttribute("id", ele.GetAttribute("id"));
                SdsiteElement.AppendChild(cEle);
            }
            base.Save();
        }
예제 #8
0
        /// <summary>
        /// 获得所有的snip节点拷贝
        /// </summary>
        public Dictionary <string, XmlElement> GetAllSnipElementClone()
        {
            Dictionary <string, XmlElement> _cloneDic = new Dictionary <string, XmlElement>();
            XmlNodeList snipNodes = this.DocumentElement.SelectNodes(@"//snip[@hasSnip='True']");

            foreach (XmlNode node in snipNodes)
            {
                XmlElement ele      = (XmlElement)node;
                XmlElement cloneEle = ele.OwnerDocument.CreateElement(ele.Name);
                XmlUtilService.CopyXmlElement(ele, cloneEle);

                string id = ele.GetAttribute("id");
                Debug.Assert(!string.IsNullOrEmpty(id));

                _cloneDic.Add(id, cloneEle);
            }

            return(_cloneDic);
        }