--- source_files: - DataPRO/DataPRO.Core/Settings/SettingsChangedEventArgs.cs - DataPRO/DataPRO.Core/Settings/SettingsCollection.cs generated_at: "2026-04-17T15:42:20.133577+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "19770357354d5bed" --- # Documentation: DataPRO.Core.Settings ## 1. Purpose This module provides an observable dictionary implementation for application settings management. The `SettingsCollection` class wraps a standard `Dictionary` and raises events when items are added, removed, modified, or when the collection is cleared. This enables consumers to react to configuration changes in real-time without polling. The module is designed to serve as the foundation for a settings system where UI components or services need to be notified when preferences change. --- ## 2. Public Interface ### `SettingsCollection` A generic dictionary implementation that implements `IDictionary` with change notification. #### Events | Signature | Description | |-----------|-------------| | `event EventHandler> CollectionItemPropertyChanged` | Fired after any mutation operation (add, remove, modify, clear). Event args contain the change type and optionally the key/item involved. | #### Constructors The class provides only the default parameterless constructor (inherited from `Object`). #### Methods | Signature | Description | |-----------|-------------| | `void Add(TKey key, TItem value)` | Adds a key-value pair to the collection. Fires `CollectionItemPropertyChanged` with `ChangeSettingType.Add`. | | `void Add(KeyValuePair item)` | Adds a key-value pair via `KeyValuePair`. Fires `CollectionItemPropertyChanged` with `ChangeSettingType.Add`. | | `bool Remove(TKey key)` | Removes the item with the specified key. Returns `true` if removed; fires event with `ChangeSettingType.Remove` only on success. | | `bool Remove(KeyValuePair item)` | Removes by `KeyValuePair.Key` (value is ignored). Fires event with `ChangeSettingType.Remove` only on success. | | `void Clear()` | Removes all items. Fires `CollectionItemPropertyChanged` with `ChangeSettingType.ClearAll`. | | `bool ContainsKey(TKey key)` | Returns `true` if the key exists. | | `bool Contains(KeyValuePair item)` | Returns `true` if both key and value match an entry in the collection. | | `bool TryGetValue(TKey key, out TItem value)` | Attempts to retrieve the value for the given key. Returns `false` if key not found. | | `IEnumerator> GetEnumerator()` | Returns an enumerator over the collection. | | `void CopyTo(KeyValuePair[] array, int arrayIndex)` | **Throws `NotImplementedException`**. | #### Properties | Signature | Description | |-----------|-------------| | `TItem this[TKey key]` (getter) | Returns the value associated with the key. Throws `KeyNotFoundException` if key absent.