Files
DP44/docs/ai/Common/DTS.Common/Classes/ChannelCodes.md

64 lines
3.0 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common/Classes/ChannelCodes/TextPastedArgs.cs
- Common/DTS.Common/Classes/ChannelCodes/ChannelCode.cs
generated_at: "2026-04-17T16:07:14.970939+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "fa1361db7a24ac6a"
---
# ChannelCodes
### Purpose
This module provides the core domain model and event handling infrastructure for channel codes, which represent coded identifiers (User or ISO type) used in channel configuration. It includes the `ChannelCode` entity class, a `PasteCommandClass` for handling clipboard paste operations with multi-field parsing, and a delegate type for coercing ISO code values. The module supports data-driven construction from database readers and integrates with the Prism event aggregation system.
### Public Interface
**ChannelCode** (class)
- Inherits from `BasePropertyChanged`, implements `IChannelCode`
- Constructors:
- `ChannelCode(IDataReader reader, IReadOnlyDictionary<short, string> channelTypeLookup)` - Constructs from database reader, mapping `CodeTypeInt` to `ChannelCodeType` via lookup
- `ChannelCode()` - Default constructor, sets `CodeType` to `ISO`
- `ChannelCode(IChannelCode channelCode)` - Copy constructor
- Properties:
- `int Id` - Unique identifier (default: -1)
- `UIItemStatus ItemStatus` - UI state (default: `UIItemStatus.None`)
- `string Code` - The channel code value
- `string Name` - The channel name
- `ChannelEnumsAndConstants.ChannelCodeType CodeType` - Either `User` or `ISO`
- `ICommand PasteCommand` - Command for paste handling (default: null)
- Constants:
- `public const string PASTE_ID = "ChannelCode"`
- Methods:
- `override bool Equals(object obj)` - Equality based on `Code`, `Name`, and `CodeType`
- Destructor: `~ChannelCode()` - Clears `_code` and `_name` to null
**PasteCommandClass** (class)
- Implements `ICommand`
- Constructor: `PasteCommandClass(string id)`
- Properties:
- `string Id { get; }` - Identifier for the command instance
- Methods:
- `bool CanExecute(object parameter)` - Always returns `true`
- `void Execute(object parameter)` - Handles paste from clipboard; parses multi-field text, publishes `TextPastedEvent` or `PageModifiedEvent`
- Events:
- `event EventHandler CanExecuteChanged`
**TextPastedArgs** (class)
- Implements `ITextPastedEventArgs`
- Constructor: `TextPastedArgs(string text, IChannelCode channelCode, string id, object tag)`
- Properties:
- `string Text { get; }` - Pasted text content
- `object Sender { get; }` - The `IChannelCode` source
- `string Id { get; }` - Identifier
- `object Tag { get; }` - Additional context
**CoerceISOCodeDelegate** (delegate)
- Signature: `delegate string CoerceISOCodeDelegate(string val, bool uniqueISOCodesRequired, bool useISOCodeFilterMapping)`
- Purpose: Coerces incoming ISO codes from UI to new values
### Invariants
- `ChannelCode.Id` defaults to -1 when not set
- `ChannelCode.Code` and `ChannelCode.Name` are never null (initialized to `string.Empty`)
- `PasteCommandClass.Execute` only processes paste if `Clipboard.ContainsText()` returns true