📄 tagnodecollection.cs
字号:
namespace Imps.Utils.TagParser
{
using System;
using System.Collections;
using System.Reflection;
public class TagNodeCollection : CollectionBase
{
private TagElement mParent;
public TagNodeCollection()
{
this.mParent = null;
}
internal TagNodeCollection(TagElement parent)
{
this.mParent = parent;
}
public int Add(TagNode node)
{
if (this.mParent != null)
{
node.SetParent(this.mParent);
}
return base.List.Add(node);
}
public void AddNodes(TagNodeCollection nodes)
{
foreach (TagNode node in nodes)
{
this.Add(node);
}
}
public TagNodeCollection Clone()
{
TagNodeCollection nodes = new TagNodeCollection();
foreach (TagNode node in base.List)
{
nodes.Add(node);
}
return nodes;
}
public TagNodeCollection FindByAttributeName(string attributeName)
{
return this.FindByAttributeName(attributeName, true);
}
public TagNodeCollection FindByAttributeName(string attributeName, bool searchChildren)
{
TagNodeCollection nodes = new TagNodeCollection(null);
foreach (TagNode node in base.List)
{
if (!(node is TagElement))
{
continue;
}
foreach (TagAttribute attribute in ((TagElement) node).Attributes)
{
if (attribute.Name.ToLower().Equals(attributeName.ToLower()))
{
nodes.Add(node);
break;
}
}
if (searchChildren)
{
foreach (TagNode node2 in ((TagElement) node).Nodes.FindByAttributeName(attributeName, searchChildren))
{
nodes.Add(node2);
}
}
}
return nodes;
}
public TagNodeCollection FindByAttributeNameValue(string attributeName, string attributeValue)
{
return this.FindByAttributeNameValue(attributeName, attributeValue, true);
}
public TagNodeCollection FindByAttributeNameValue(string attributeName, string attributeValue, bool searchChildren)
{
TagNodeCollection nodes = new TagNodeCollection(null);
foreach (TagNode node in base.List)
{
if (!(node is TagElement))
{
continue;
}
foreach (TagAttribute attribute in ((TagElement) node).Attributes)
{
if (attribute.Name.ToLower().Equals(attributeName.ToLower()))
{
if (attribute.Value.ToLower().Equals(attributeValue.ToLower()))
{
nodes.Add(node);
}
break;
}
}
if (searchChildren)
{
foreach (TagNode node2 in ((TagElement) node).Nodes.FindByAttributeNameValue(attributeName, attributeValue, searchChildren))
{
nodes.Add(node2);
}
}
}
return nodes;
}
public TagNodeCollection FindByName(string name)
{
return this.FindByName(name, true);
}
public TagNodeCollection FindByName(string name, bool searchChildren)
{
TagNodeCollection nodes = new TagNodeCollection(null);
foreach (TagNode node in base.List)
{
if (node is TagElement)
{
if (((TagElement) node).Name.ToLower().Equals(name.ToLower()))
{
nodes.Add(node);
}
if (searchChildren)
{
foreach (TagNode node2 in ((TagElement) node).Nodes.FindByName(name, searchChildren))
{
nodes.Add(node2);
}
}
}
}
return nodes;
}
public int IndexOf(TagNode node)
{
return base.List.IndexOf(node);
}
public void Insert(int index, TagNode node)
{
if (this.mParent != null)
{
node.SetParent(this.mParent);
}
base.InnerList.Insert(index, node);
}
public TagNode this[string name]
{
get
{
TagNodeCollection nodes = this.FindByName(name, false);
if (nodes.Count > 0)
{
return nodes[0];
}
return null;
}
}
public TagNode this[int index]
{
get
{
return (TagNode) base.InnerList[index];
}
set
{
if (this.mParent != null)
{
value.SetParent(this.mParent);
}
base.InnerList[index] = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -