public string Attribute(string name)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
// Note: we don't check for validity here because an
// if an invalid name is passed we simply won't find it.
if (_attributes == null)
return null;
// Go through all the attribute and see if we know about
// the one we are asked for
int iMax = _attributes.Count;
Debug.Assert(iMax % 2 == 0, "Odd number of strings means the attr/value pairs were not added correctly");
for (int i = 0; i < iMax; i += 2)
{
string strAttrName = (string)_attributes[i];
if (string.Equals(strAttrName, name))
{
string strAttrValue = (string)_attributes[i + 1];
return Unescape(strAttrValue);
}
}
// In the case where we didn't find it, we are expected to
// return null
return null;
}