Class AttributeCollection
A collection of HTML name/value attributes.
Inheritance
Implements
Inherited Members
Namespace: EPiServer.HtmlParsing
Assembly: EPiServer.Framework.dll
Version: 9.12.2Syntax
public class AttributeCollection : ICollection<AttributeFragment>, IEnumerable<AttributeFragment>, IEnumerable
Remarks
Note that a name may appear multiple times.
Constructors
AttributeCollection()
Initializes a new instance of the AttributeCollection class.
Declaration
public AttributeCollection()
Properties
Count
Gets the number of elements contained in the System.Collections.Generic.ICollection<T>.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsReadOnly
Gets a value indicating whether the System.Collections.Generic.ICollection<T> is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Item[Int32]
Gets or sets the AttributeFragment at the specified index.
Declaration
public AttributeFragment this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
AttributeFragment | The attribute fragment. |
Item[String]
Gets the AttributeFragment with the specified key.
Declaration
public AttributeFragment this[string key] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | key |
Property Value
Type | Description |
---|---|
AttributeFragment | The attribute fragment. |
Remarks
The key matching is done in a case-insensitive manner.
Since an attribute name may appear multiple times, this property will return the first instance. In order to access all instances with the given key, you need to iterate thru the collection and check each entry.
Methods
Add(AttributeFragment)
Adds an item to the System.Collections.Generic.ICollection<T>.
Declaration
public void Add(AttributeFragment item)
Parameters
Type | Name | Description |
---|---|---|
AttributeFragment | item | The object to add to the System.Collections.Generic.ICollection<T>. |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | The System.Collections.Generic.ICollection<T> is read-only. |
Clear()
Removes all items from the System.Collections.Generic.ICollection<T>.
Declaration
public void Clear()
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | The System.Collections.Generic.ICollection<T> is read-only. |
Contains(AttributeFragment)
Determines whether the System.Collections.Generic.ICollection<T> contains a specific value.
Declaration
public bool Contains(AttributeFragment item)
Parameters
Type | Name | Description |
---|---|---|
AttributeFragment | item | The object to locate in the System.Collections.Generic.ICollection<T>. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
CopyTo(AttributeFragment[], Int32)
Copies the elements of the System.Collections.Generic.ICollection<T> to an System.Array, starting at a particular System.Array index.
Declaration
public void CopyTo(AttributeFragment[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
AttributeFragment[] | array | The one-dimensional System.Array that is the destination of the elements copied from System.Collections.Generic.ICollection<T>. The System.Array must have zero-based indexing. |
System.Int32 | arrayIndex | The zero-based index in |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
System.ArgumentException |
|
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<AttributeFragment> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<AttributeFragment> | A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection. |
Remove(AttributeFragment)
Declaration
public bool Remove(AttributeFragment item)
Parameters
Type | Name | Description |
---|---|---|
AttributeFragment | item |
Returns
Type | Description |
---|---|
System.Boolean |
Remove(String)
Removes the attribute with the specified key.
Declaration
public bool Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
Returns
Type | Description |
---|---|
System.Boolean | True if an attribute was removed, false otherwise. |
Remarks
The key matching is done in a case-insensitive manner.
If there are more than one attribute with the specified key, only the first attribute is removed.
RemoveAll(String)
Removes all attributes with the specified key.
Declaration
public int RemoveAll(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
Returns
Type | Description |
---|---|
System.Int32 |
RemoveAt(Int32)
Removes the attribute at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
TryGetValue(String, out AttributeFragment)
Declaration
public bool TryGetValue(string key, out AttributeFragment value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | |
AttributeFragment | value |
Returns
Type | Description |
---|---|
System.Boolean |
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | An System.Collections.IEnumerator object that can be used to iterate through the collection. |