AttrExtensions
Extensions for the list of attributes.
using AngleSharp.Dom;
using System.Collections.Generic;
using System.Diagnostics;
namespace AngleSharp.Extensions
{
[DebuggerStepThrough]
internal static class AttrExtensions
{
public static bool Has(this List<IAttr> attributes, string name)
{
for (int i = 0; i < attributes.Count; i++) {
if (attributes[i].Name == name)
return true;
}
return false;
}
public static bool Has(this List<IAttr> attributes, string namespaceUri, string localName)
{
for (int i = 0; i < attributes.Count; i++) {
if (attributes[i].NamespaceUri == namespaceUri && attributes[i].LocalName == localName)
return true;
}
return false;
}
public static IAttr Get(this List<IAttr> attributes, string name)
{
for (int i = 0; i < attributes.Count; i++) {
if (attributes[i].Name == name)
return attributes[i];
}
return null;
}
public static IAttr Get(this List<IAttr> attributes, string namespaceUri, string localName)
{
for (int i = 0; i < attributes.Count; i++) {
if (attributes[i].NamespaceUri == namespaceUri && attributes[i].LocalName == localName)
return attributes[i];
}
return null;
}
public static bool AreEqual(this List<IAttr> sourceAttributes, List<IAttr> targetAttributes)
{
if (sourceAttributes.Count != targetAttributes.Count)
return false;
for (int i = 0; i < sourceAttributes.Count; i++) {
IAttr attr = sourceAttributes[i];
bool flag = false;
for (int j = 0; j < targetAttributes.Count; j++) {
IAttr attr2 = targetAttributes[j];
if (flag = (attr.Name == attr2.Name && attr.NamespaceUri == attr2.NamespaceUri && attr.Value == attr2.Value))
break;
}
if (!flag)
return false;
}
return true;
}
}
}