Class Attributes
The attributes of an Element.
Inheritance
Namespace: Supremes.Nodes
Assembly: Supremes.dll
Syntax
public sealed class Attributes : IEnumerable<Attribute>
Remarks
Attributes are treated as a map: there can be only one value associated with an attribute key.
Attribute key and value comparisons are done case insensitively, and keys are normalised to lower-case.
Properties
Count
Get the number of attributes in this set.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | size |
Dataset
Retrieves a filtered view of attributes that are HTML5 custom data attributes; that is, attributes with keys
starting with
data-
.
Declaration
public IDictionary<string, string> Dataset { get; }
Property Value
Type | Description |
---|---|
IDictionary<System.String, System.String> | map of custom data attributes. |
Html
Get the HTML representation of these attributes.
Declaration
public string Html { get; }
Property Value
Type | Description |
---|---|
System.String | HTML |
Item[String]
Get an attribute value by key. Set a new attribute, or replace an existing one by key.
Declaration
public string this[string key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | key | the attribute key |
Property Value
Type | Description |
---|---|
System.String | attribute value |
See Also
Methods
AsList()
Get the attributes as a List, for iteration.
Declaration
public IReadOnlyList<Attribute> AsList()
Returns
Type | Description |
---|---|
IReadOnlyList<Attribute> | an view of the attributes as a List. |
Remarks
Get the attributes as a List, for iteration. Do not modify the keys of the attributes via this view, as changes to keys will not be recognised in the containing set.
ContainsKey(String)
Tests if these attributes contain an attribute with this key.
Declaration
public bool ContainsKey(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | key to check for |
Returns
Type | Description |
---|---|
System.Boolean | true if key exists, false otherwise |
Equals(Object)
Compares two Attributes instances for equality.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
GetEnumerator()
Returns an enumerator that iterates through the Attributes.
Declaration
public IEnumerator<Attribute> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<Attribute> |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Put(Attribute)
Set a new attribute, or replace an existing one by key.
Declaration
public void Put(Attribute attribute)
Parameters
Type | Name | Description |
---|---|---|
Attribute | attribute | attribute |
Remove(String)
Remove an attribute by key.
Declaration
public void Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | attribute key to remove |
SetAll(Attributes)
Add all the attributes from the incoming set to this set.
Declaration
public void SetAll(Attributes incoming)
Parameters
Type | Name | Description |
---|---|---|
Attributes | incoming | attributes to add to these attributes. |
ToString()
Converts the value of this instance to a string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |