AngleSharp by AngleSharp

<PackageReference Include="AngleSharp" Version="1.2.0" />

 StructAttributes

public struct StructAttributes
Struct to hold attributes.
using AngleSharp.Common; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; namespace AngleSharp.Html.Parser.Tokens.Struct { public struct StructAttributes { private int _count; private MemoryHtmlAttributeToken _t0; private MemoryHtmlAttributeToken _t1; private MemoryHtmlAttributeToken _t2; private MemoryHtmlAttributeToken _t3; [System.Runtime.CompilerServices.Nullable(1)] private List<MemoryHtmlAttributeToken> _tail; public int Count => _count; public MemoryHtmlAttributeToken this[int id] { get { if (id < _count) { switch (id) { case 0: return _t0; case 1: return _t1; case 2: return _t2; case 3: return _t3; default: return _tail[id - 4]; } } throw new ArgumentOutOfRangeException("id"); } set { if (id >= _count) throw new ArgumentOutOfRangeException("id"); switch (id) { case 0: _t0 = value; break; case 1: _t1 = value; break; case 2: _t2 = value; break; case 3: _t3 = value; break; default: _tail[id - 4] = value; break; } } } public void Add(MemoryHtmlAttributeToken item) { int count = _count; if (count <= 3) { switch (count) { case 0: _t0 = item; _count = 1; break; case 1: _t1 = item; _count = 2; break; case 2: _t2 = item; _count = 3; break; case 3: _t3 = item; _count = 4; break; } } else { if (_tail == null) _tail = new List<MemoryHtmlAttributeToken>(2); _tail.Add(item); _count++; } } public void RemoveAt(int index) { if (index > _count) throw new ArgumentOutOfRangeException("index"); switch (_count) { case 1: _t0 = default(MemoryHtmlAttributeToken); break; case 2: if (index == 0) { _t0 = _t1; _t1 = default(MemoryHtmlAttributeToken); } else _t1 = default(MemoryHtmlAttributeToken); break; case 3: switch (index) { case 0: _t0 = _t1; _t1 = _t2; _t2 = default(MemoryHtmlAttributeToken); break; case 1: _t1 = _t2; _t2 = default(MemoryHtmlAttributeToken); break; default: _t2 = default(MemoryHtmlAttributeToken); break; } break; case 4: switch (index) { case 0: _t0 = _t1; _t1 = _t2; _t2 = _t3; _t3 = default(MemoryHtmlAttributeToken); break; case 1: _t1 = _t2; _t2 = _t3; _t3 = default(MemoryHtmlAttributeToken); break; case 2: _t2 = _t3; _t3 = default(MemoryHtmlAttributeToken); break; default: _t3 = default(MemoryHtmlAttributeToken); break; } break; default: switch (index) { case 0: _t0 = _t1; _t1 = _t2; _t2 = _t3; _t3 = _tail[0]; _tail.RemoveAt(0); break; case 1: _t1 = _t2; _t2 = _t3; _t3 = _tail[0]; _tail.RemoveAt(0); break; case 2: _t2 = _t3; _t3 = _tail[0]; _tail.RemoveAt(0); break; case 3: _t3 = _tail[0]; _tail.RemoveAt(0); break; default: _tail.RemoveAt(index - 4); break; } break; } _count--; } public bool HasAttribute(StringOrMemory name, StringOrMemory value) { for (int i = 0; i < _count; i++) { MemoryHtmlAttributeToken memoryHtmlAttributeToken = this[i]; StringOrMemory stringOrMemory = memoryHtmlAttributeToken.Name; if (stringOrMemory.Equals(name)) { stringOrMemory = memoryHtmlAttributeToken.Value; if (stringOrMemory.Equals(value)) return true; } } return false; } } }