HtmlAllCollection
sealed class HtmlAllCollection : IHtmlAllCollection, IHtmlCollection<IElement>, IEnumerable<IElement>, IEnumerable
A general collection for all elements of type IElement.
using AngleSharp.Extensions;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace AngleSharp.Dom.Collections
{
internal sealed class HtmlAllCollection : IHtmlAllCollection, IHtmlCollection<IElement>, IEnumerable<IElement>, IEnumerable
{
private readonly IEnumerable<IElement> _elements;
public IElement this[int index] {
get {
return _elements.GetItemByIndex(index);
}
}
public IElement this[string id] {
get {
return _elements.GetElementById(id);
}
}
public int Length => _elements.Count();
public HtmlAllCollection(IDocument document)
{
_elements = document.GetElements<IElement>(true, null);
}
public IEnumerator<IElement> GetEnumerator()
{
return _elements.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return _elements.GetEnumerator();
}
}
}