6.9 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T04:47:50.422558+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 3c94987e004e61ba |
ViewModel
Documentation: RealtimeChannelSelectViewModel
1. Purpose
RealtimeChannelSelectViewModel is a Prism-based ViewModel responsible for managing the UI state and logic of the Realtime Channel Selection view. It exposes a list of available real-time channels, supports filtering them by user-provided search text, and publishes selection events when a channel is chosen. It integrates with the application’s event system via IEventAggregator to coordinate with other modules (e.g., signaling busy state, displaying notifications, and publishing channel selections). It does not implement complex business logic itself but serves as a thin presentation layer adapter between the view and the underlying event-driven architecture.
2. Public Interface
-
IRealtimeChannelSelectView ChannelSelectView { get; set; }
Reference to the associated view (IRealtimeChannelSelectView). Set during construction and used to bindDataContext. -
InteractionRequest<Notification> NotificationRequest { get; }
PrismInteractionRequestused to trigger notification popups (e.g., alerts, messages). Raised viaOnRaiseNotification. -
InteractionRequest<Confirmation> ConfirmationRequest { get; }
PrismInteractionRequestfor confirmation dialogs (currently unused in the provided code). -
event PropertyChangedEventHandler PropertyChanged
StandardINotifyPropertyChangedimplementation. Used to notify UI of property changes. -
void OnPropertyChanged(string propertyName)
Helper to raisePropertyChangedevent for a given property. -
void SetAvailableChannels(IRealtimeChannel[] channels)
Sets the full, unfiltered list of channels. Triggers filtering and updatesRealtimeChannels. -
void SetSearchText(string searchText)
Updates the internal search term and re-applies filtering. Channels whoseToString()representation contains the search term (case-insensitive, culture-sensitive) are included. -
void SetRealtimeChannel(IRealtimeChannel channel)
Publishes the selected channel via theRealtimeChannelSelectedEventevent. -
void Unset(),void Cleanup(),Task CleanupAsync(),void Initialize(),void Initialize(object),void Initialize(object, object),Task InitializeAsync(),Task InitializeAsync(object),void Activated()
Lifecycle stubs required by Prism’sINavigationAware,IInitializeAsync, etc. interfaces. All are currently empty and have no effect. -
bool IsBusy { get; set; }
Bindable property indicating whether the UI should show a busy indicator. Set via subscription toBusyIndicatorChangeNotification. -
bool IsMenuIncluded { get; set; }
Bindable property indicating whether the menu UI section should be visible. -
bool IsNavigationIncluded { get; set; }
Bindable property indicating whether the navigation UI section should be visible. -
IRealtimeChannel[] RealtimeChannels { get; set; }
Bindable array of filtered channels to display in the view. Initialized to an empty array. -
bool IsDirty => false
Always returnsfalse. Indicates no unsaved changes (not implemented).
3. Invariants
RealtimeChannelsalways reflects the current filtered view of_allChannelsafterSetAvailableChannelsorSetSearchTextis called._searchTermis used case-insensitively (viaCultureInfo.CurrentCulture.CompareInfo) to filter channels by theirToString()representation.IsBusyis updated synchronously on the publisher thread (due toThreadOption.PublisherThreadin subscription)._allChannelsis nevernullafterSetAvailableChannelsis called (though it may be an empty array).RealtimeChannelSelectedEventis published only whenSetRealtimeChannelis invoked.NotificationRequestis always raised with aNotificationobject containing aNotificationContentEventArgs(with emptyFooterandFooterCommandfields) and the original title.
4. Dependencies
Imports / Dependencies (from source):
DTS.Common.Events,DTS.Common.Events.Realtime,DTS.Common.Interactivity,DTS.Common.Interface.Realtime
→ Defines core event types (RaiseNotification,BusyIndicatorChangeNotification,RealtimeChannelSelectedEvent) and interfaces (IRealtimeChannel,IRealtimeChannelSelectView,IRealtimeChannelSelectViewModel).Prism.Events,Prism.Regions,Unity
→ Prism framework for event aggregation, region management, and Unity DI container.System.ComponentModel,System.Linq,System.Threading.Tasks
→ Standard .NET types for INPC, LINQ, async.
Consumers (inferred):
- Any module/component that needs to display notifications via
RaiseNotificationor control busy state viaBusyIndicatorChangeNotification. - Any module that needs to respond to channel selection via
RealtimeChannelSelectedEvent. - The view (
IRealtimeChannelSelectView) binds toRealtimeChannels,IsBusy,IsMenuIncluded,IsNavigationIncluded, and commands (none defined here).
Dependencies on this module:
- The view (
IRealtimeChannelSelectView) depends on this ViewModel for data binding. - Other modules subscribe to
RealtimeChannelSelectedEventto react to user selections.
5. Gotchas
ToString()-based filtering: Filtering relies onchannel.ToString(), which may be implementation-specific (e.g., default type name or overridden). EnsureIRealtimeChannelimplementations provide meaningfulToString()output for search to work as intended.- Empty lifecycle methods: All Prism lifecycle methods (
Initialize,Cleanup, etc.) are no-ops. If initialization/cleanup logic is needed, it must be added. IsDirtyalwaysfalse: TheIsDirtyproperty is hardcoded tofalse. If dirty-state tracking is required, it is not implemented here.- Culture-specific search: Search uses
CultureInfo.CurrentCulture. Behavior may vary across locales (e.g., Turkish i problem). ConsiderCultureInfo.InvariantCultureif consistent behavior across locales is required. - Thread safety:
_allChannelsand_searchTermare not thread-safe.Filter()is called synchronously fromSetAvailableChannels/SetSearchText, but if those are invoked from non-UI threads, race conditions may occur (though unlikely given Prism conventions). - Unused
ConfirmationRequest: TheConfirmationRequestis declared but never used—potential tech debt or placeholder. - No command bindings: The
#region Commandssection is empty. UI interaction (e.g., channel selection) likely occurs via direct method calls from the view (e.g.,SetRealtimeChannel), not PrismICommandbindings.
None identified beyond the above.