Files
DP44/docs/ai/Common/DTS.Common.Core/Settings.md

39 lines
2.1 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common.Core/Settings/SettingsChangedEventArgs.cs
- Common/DTS.Common.Core/Settings/SettingsCollection.cs
generated_at: "2026-04-17T15:40:38.741606+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "a2f3cb745d88ce73"
---
# Documentation: DTS.Common.Core.Settings
## 1. Purpose
This module provides an observable dictionary implementation for managing application settings. 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. The module exists to provide change-notification semantics for settings management, allowing dependent components to synchronize state when settings are mutated.
---
## 2. Public Interface
### `SettingsCollection<TKey, TItem>`
A generic dictionary implementation that implements `IDictionary<TKey, TItem>` with change notification support.
#### Event
| Signature | Description |
|-----------|-------------|
| `event EventHandler<SettingsChangedEventArgs<TKey, TItem>> CollectionItemPropertyChanged` | Fired after any mutation operation (add, remove, modify, clear) on the collection. |
#### Methods
| Signature | Description |
|-----------|-------------|
| `void Add(TKey key, TItem value)` | Adds a key-value pair to the collection and fires `CollectionItemPropertyChanged` with `ChangeSettingType.Add`. |
| `void Add(KeyValuePair<TKey, TItem> item)` | Adds a key-value pair via `KeyValuePair` and fires `CollectionItemPropertyChanged` with `ChangeSettingType.Add`. |
| `bool Remove(TKey key)` | Removes the item with the specified key. Returns `true` if removed; fires `CollectionItemPropertyChanged` with `ChangeSettingType.Remove` only on successful removal. |
| `bool Remove(KeyValuePair<TKey, TItem> item)` | Removes by key (value is ignored). Returns `true` if removed; fires `CollectionItemPropertyChanged` with `ChangeSettingType.Remove` only on successful removal. |
| `void Clear()` | Clears all items and fires `CollectionItemPropertyChanged` with `ChangeSetting