Beispiel #1
0
        /// <summary>
        /// 根据标签名获取所有同标签名的子元素标签
        /// </summary>
        /// <param name="tagName"></param>
        /// <returns></returns>
        public virtual DMEWeb_ElementCollection<DMEWeb_Tag> GetChildTagsByTagName(string tagName)
        {
            if (string.IsNullOrEmpty(tagName)) throw new ArgumentNullException("tagName");

            DMEWeb_ElementCollection<DMEWeb_Tag> tags = new DMEWeb_ElementCollection<DMEWeb_Tag>();
            //搜索当前元素下的子元素
            foreach (DMEWeb_Element item in this.InnerElements)
            {
                if (item is DMEWeb_Tag)
                {
                    DMEWeb_Tag tag = (DMEWeb_Tag)item;
                    if (tagName.Equals(tag.TagName, StringComparison.InvariantCultureIgnoreCase)) tags.Add(tag);

                    //处理其下子元素
                    tags.AddRange(tag.GetChildTagsByTagName(tagName));
                }
            }
            return tags;
        }
Beispiel #2
0
        /// <summary>
        /// 获取所有具有同名称的模板列表.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public DMEWeb_ElementCollection<DMEWeb_Template> GetChildTemplatesByName(string name)
        {
            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name");

            DMEWeb_ElementCollection<DMEWeb_Template> items = new DMEWeb_ElementCollection<DMEWeb_Template>();
            foreach (DMEWeb_Template template in TagContainer.ChildTemplates)
            {
                if (name.Equals(template.Name, StringComparison.InvariantCultureIgnoreCase))
                {
                    items.Add(template);
                }
                items.AddRange(template.GetChildTemplatesByName(name));
            }
            return items;
        }