Table of Contents

Class MetadataCollection

Namespace
LMKit.Data
Assembly
LM-Kit.NET.dll

Represents a collection of metadata entries, each consisting of a key and a value. This class provides methods to manage metadata efficiently, allowing addition, removal, and key-based queries.

public sealed class MetadataCollection : IList<Metadata>, ICollection<Metadata>, IEnumerable<Metadata>, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
Inheritance
MetadataCollection
Implements
Inherited Members

Examples

var metadata = new MetadataCollection();
metadata.Add("Author", "John Doe");
metadata.Add("Title", "Sample Document");

if (metadata.TryGetValue("Author", out string author))
{
    Console.WriteLine($"Author: {author}");
}

Remarks

The collection enforces unique keys; attempting to add a duplicate key will result in an exception.

This class implements INotifyCollectionChanged and INotifyPropertyChanged to support data binding scenarios.

Constructors

MetadataCollection()

Initializes a new instance of the MetadataCollection class that is empty.

MetadataCollection(MetadataCollection)

Initializes a new instance of the MetadataCollection class that contains the metadata entries copied from the specified MetadataCollection.

Properties

Count

Gets the number of metadata entries currently in the collection.

this[int]

Gets or sets the metadata entry at the specified zero-based index.

Methods

Add(Metadata)

Adds a metadata entry to the collection.

Add(MetadataCollection)

Adds all metadata entries from another MetadataCollection to this collection.

Add(KeyValuePair<string, string>)

Adds a metadata entry to the collection using a key-value pair.

Add(string, string)

Adds a metadata entry to the collection by specifying a key and a value.

AddOrReplace(Metadata)

Adds a metadata entry to the collection, or replaces an existing entry with the same key.

AddOrReplace(MetadataCollection)

Adds or replaces metadata entries from the specified collection.

Clear()

Removes all metadata entries from the collection.

Clone()

Creates a deep copy of the current MetadataCollection instance.

Contains(Metadata)

Determines whether the metadata collection contains the specified metadata entry.

Contains(MetadataCollection)

Determines whether the current collection contains all keys from the specified metadata collection.

ContainsKey(string)

Determines whether a metadata entry with the specified key exists in the collection.

ElementAt(int)

Retrieves the metadata entry at the specified zero-based index.

Get(string)

Retrieves the metadata entry with the specified key.

GetEnumerator()

Returns an enumerator that iterates through the metadata entries in the collection.

IndexOf(Metadata)

Returns the zero-based index of the first occurrence of the specified metadata entry in the collection.

Insert(int, Metadata)

Inserts a metadata entry into the collection at the specified index.

Remove(Metadata)

Removes the specified metadata entry from the collection.

Remove(string)

Removes the first metadata entry with the specified key from the collection.

RemoveAt(int)

Removes the metadata entry at the specified index.

TryGet(string, out Metadata)

Attempts to retrieve the metadata entry with the specified key.

TryGetValue(string, out string)

Attempts to retrieve the value associated with the specified key.

Events

CollectionChanged

Occurs when the collection changes, such as when items are added, removed, replaced, or the entire list is refreshed.

PropertyChanged

Occurs when a property value changes.