Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Diagnostics.​ActivityTagsCollection

Assembly: System.Diagnostics.DiagnosticSource

Inheritance: object → ActivityTagsCollection

Implemented Interfaces

ActivityTagsCollection is a collection class used to store tracing tags. This collection will be used with classes like <see cref="T:System.Diagnostics.ActivityEvent" /> and <see cref="T:System.Diagnostics.ActivityLink" /> . This collection behaves as follows: - The collection items will be ordered according to how they are added. - Don't allow duplication of items with the same key. - When using the indexer to store an item in the collection: - If the item has a key that previously existed in the collection and the value is <see langword="null" /> , the collection item matching the key will be removed from the collection. - If the item has a key that previously existed in the collection and the value is not <see langword="null" /> , the new item value will replace the old value stored in the collection. - Otherwise, the item will be added to the collection. - Add method will add a new item to the collection if an item doesn't already exist with the same key. Otherwise, it will throw an exception.

Properties

public object
Item
Keys
Get the list of the keys of all stored tags.
Values
Get the list of the values of all stored tags.
public int
Count
Gets the number of elements contained in the collection.
public bool
IsReadOnly
Gets a value indicating whether the collection is read-only. This always returns <see langword="false" /> .

Methods

public void
Add​(string key, object value)
Adds a tag with the provided key and value to the collection. This collection doesn't allow adding two tags with the same key.
key The tag key.
value The tag value.
public void
Add​(Collections.​Generic.​KeyValuePair<​string, object> item)
Adds an item to the collection.
item Key and value pair of the tag to add to the collection.
public void
Clear​()
Removes all items from the collection.
public bool
Contains​(Collections.​Generic.​KeyValuePair<​string, object> item)
Determines whether the <see cref="T:System.Collections.Generic.ICollection`1" /> contains a specific value.
Returns <see langword="true" /> if <paramref name="item" /> is found in the <see cref="T:System.Collections.Generic.ICollection`1" /> ; otherwise, <see langword="false" /> .
item The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1" /> .
public bool
ContainsKey​(string key)
Determines whether the collection contains an element with the specified key.
Returns <see langword="true" /> if the collection contains tag with that key. <see langword="false" /> otherwise.
key The key to locate in the <see cref="T:System.Collections.Generic.IDictionary`2" /> .
public void
CopyTo​(Collections.​Generic.​KeyValuePair[] array, int arrayIndex)
Copies the elements of the collection to an array, starting at a particular array index.
array The array that is the destination of the elements copied from collection.
arrayIndex The zero-based index in array at which copying begins.
public bool
Remove​(string key)
Removes the tag with the specified key from the collection.
Returns <see langword="true" /> if the item existed and removed. <see langword="false" /> otherwise.
key The tag key.
public bool
Remove​(Collections.​Generic.​KeyValuePair<​string, object> item)
Removes the first occurrence of a specific item from the collection.
Returns <see langword="true" /> if item was successfully removed from the collection; otherwise, <see langword="false" /> . This method also returns <see langword="false" /> if item is not found in the original collection.
item The tag key value pair to remove.
public bool
TryGetValue​(string key, Object&? value)
public Enumerator
GetEnumerator​()
Returns an enumerator that iterates through the collection.
Returns An enumerator for the <see langword="ActivityTagsCollection" /> .
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object