AngleSharp by AngleSharp

<PackageReference Include="AngleSharp" Version="0.16.0-alpha-80" />

.NET API 879,104 bytes

 Attr

Represents a generic node attribute.
using AngleSharp.Dom.Events; using AngleSharp.Text; using System; using System.IO; using System.Runtime.CompilerServices; namespace AngleSharp.Dom { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public sealed class Attr : IAttr, INode, IEventTarget, IMarkupFormattable, IEquatable<IAttr> { private readonly string _localName; [System.Runtime.CompilerServices.Nullable(2)] private readonly string _prefix; [System.Runtime.CompilerServices.Nullable(2)] private readonly string _namespace; private string _value; [System.Runtime.CompilerServices.Nullable(2)] [field: System.Runtime.CompilerServices.Nullable(2)] internal NamedNodeMap Container { [System.Runtime.CompilerServices.NullableContext(2)] get; [System.Runtime.CompilerServices.NullableContext(2)] set; } public bool IsSpecified => true; [System.Runtime.CompilerServices.Nullable(2)] public IElement OwnerElement { [System.Runtime.CompilerServices.NullableContext(2)] get { return Container?.Owner; } } [System.Runtime.CompilerServices.Nullable(2)] public string Prefix { [System.Runtime.CompilerServices.NullableContext(2)] get { return _prefix; } } public bool IsId { get { if (_prefix == null) return _localName.Isi(AttributeNames.Id); return false; } } public bool Specified => !string.IsNullOrEmpty(_value); public string Name { get { if (_prefix != null) return _prefix + ":" + _localName; return _localName; } } public string Value { get { return _value; } set { string value2 = _value; _value = value; Container?.RaiseChangedEvent(this, value, value2); } } public string LocalName => _localName; [System.Runtime.CompilerServices.Nullable(2)] public string NamespaceUri { [System.Runtime.CompilerServices.NullableContext(2)] get { return _namespace; } } string INode.BaseUri { get { return OwnerElement.BaseUri; } } [System.Runtime.CompilerServices.Nullable(2)] Url INode.BaseUrl { [System.Runtime.CompilerServices.NullableContext(2)] get { return OwnerElement?.BaseUrl; } } string INode.NodeName { get { return Name; } } INodeList INode.ChildNodes { get { return NodeList.Empty; } } [System.Runtime.CompilerServices.Nullable(2)] IDocument INode.Owner { [System.Runtime.CompilerServices.NullableContext(2)] get { return OwnerElement?.Owner; } } [System.Runtime.CompilerServices.Nullable(2)] IElement INode.ParentElement { [System.Runtime.CompilerServices.NullableContext(2)] get { return null; } } [System.Runtime.CompilerServices.Nullable(2)] INode INode.Parent { [System.Runtime.CompilerServices.NullableContext(2)] get { return null; } } [System.Runtime.CompilerServices.Nullable(2)] INode INode.FirstChild { [System.Runtime.CompilerServices.NullableContext(2)] get { return null; } } [System.Runtime.CompilerServices.Nullable(2)] INode INode.LastChild { [System.Runtime.CompilerServices.NullableContext(2)] get { return null; } } [System.Runtime.CompilerServices.Nullable(2)] INode INode.NextSibling { [System.Runtime.CompilerServices.NullableContext(2)] get { return null; } } [System.Runtime.CompilerServices.Nullable(2)] INode INode.PreviousSibling { [System.Runtime.CompilerServices.NullableContext(2)] get { return null; } } NodeType INode.NodeType { get { return NodeType.Attribute; } } string INode.NodeValue { get { return Value; } set { Value = value; } } string INode.TextContent { get { return Value; } set { Value = value; } } bool INode.HasChildNodes { get { return false; } } NodeFlags INode.Flags { get { throw new NotImplementedException(); } } public Attr(string localName) : this(localName, string.Empty) { } public Attr(string localName, string value) { _localName = localName; _value = value; } public Attr([System.Runtime.CompilerServices.Nullable(2)] string prefix, string localName, string value, [System.Runtime.CompilerServices.Nullable(2)] string namespaceUri) { _prefix = prefix; _localName = localName; _value = value; _namespace = namespaceUri; } public bool Equals(IAttr other) { if (Prefix.Is(other.Prefix) && NamespaceUri.Is(other.NamespaceUri)) return Value.Is(other.Value); return false; } public override int GetHashCode() { return (((1 * 31 + _localName.GetHashCode()) * 31 + (_value ?? string.Empty).GetHashCode()) * 31 + (_namespace ?? string.Empty).GetHashCode()) * 31 + (_prefix ?? string.Empty).GetHashCode(); } INode INode.Clone(bool deep) { return new Attr(_prefix, _localName, _value, _namespace); } bool INode.Equals(INode otherNode) { IAttr attr = otherNode as IAttr; if (attr != null) return Equals(attr); return false; } DocumentPositions INode.CompareDocumentPosition(INode otherNode) { return OwnerElement?.CompareDocumentPosition(otherNode) ?? DocumentPositions.Disconnected; } void INode.Normalize() { } bool INode.Contains(INode otherNode) { return false; } bool INode.IsDefaultNamespace(string namespaceUri) { return OwnerElement?.IsDefaultNamespace(namespaceUri) ?? false; } [return: System.Runtime.CompilerServices.Nullable(2)] string INode.LookupNamespaceUri(string prefix) { return OwnerElement?.LookupNamespaceUri(prefix); } [return: System.Runtime.CompilerServices.Nullable(2)] string INode.LookupPrefix(string namespaceUri) { return OwnerElement?.LookupPrefix(namespaceUri); } INode INode.AppendChild(INode child) { throw new DomException(DomError.NotSupported); } INode INode.InsertBefore(INode newElement, [System.Runtime.CompilerServices.Nullable(2)] INode referenceElement) { throw new DomException(DomError.NotSupported); } INode INode.RemoveChild(INode child) { throw new DomException(DomError.NotSupported); } INode INode.ReplaceChild(INode newChild, INode oldChild) { throw new DomException(DomError.NotSupported); } void IEventTarget.AddEventListener(string type, [System.Runtime.CompilerServices.Nullable(2)] DomEventHandler callback, bool capture) { throw new DomException(DomError.NotSupported); } void IEventTarget.RemoveEventListener(string type, [System.Runtime.CompilerServices.Nullable(2)] DomEventHandler callback, bool capture) { throw new DomException(DomError.NotSupported); } void IEventTarget.InvokeEventListener(Event ev) { throw new DomException(DomError.NotSupported); } bool IEventTarget.Dispatch(Event ev) { throw new DomException(DomError.NotSupported); } void IMarkupFormattable.ToHtml(TextWriter writer, IMarkupFormatter formatter) { } } }