54 lines
2.9 KiB
Markdown
54 lines
2.9 KiB
Markdown
|
|
---
|
||
|
|
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<TKey, TItem>` class wraps a standard `Dictionary<TKey, TItem>` 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<TKey, TItem>`
|
||
|
|
|
||
|
|
A generic dictionary implementation that implements `IDictionary<TKey, TItem>` with change notification.
|
||
|
|
|
||
|
|
#### Events
|
||
|
|
|
||
|
|
| Signature | Description |
|
||
|
|
|-----------|-------------|
|
||
|
|
| `event EventHandler<SettingsChangedEventArgs<TKey, TItem>> 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<TKey, TItem> 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<TKey, TItem> 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<TKey, TItem> 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<KeyValuePair<TKey, TItem>> GetEnumerator()` | Returns an enumerator over the collection. |
|
||
|
|
| `void CopyTo(KeyValuePair<TKey, TItem>[] 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.
|