Files
DP44/enriched-qwen3-coder-next/DataPRO/Modules/Realtime/RealtimeModule/ViewModel.md
2026-04-17 14:55:32 -04:00

6.9 KiB
Raw Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/Realtime/RealtimeModule/ViewModel/RealtimeChannelSelectViewModel.cs
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 applications 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 bind DataContext.

  • InteractionRequest<Notification> NotificationRequest { get; }
    Prism InteractionRequest used to trigger notification popups (e.g., alerts, messages). Raised via OnRaiseNotification.

  • InteractionRequest<Confirmation> ConfirmationRequest { get; }
    Prism InteractionRequest for confirmation dialogs (currently unused in the provided code).

  • event PropertyChangedEventHandler PropertyChanged
    Standard INotifyPropertyChanged implementation. Used to notify UI of property changes.

  • void OnPropertyChanged(string propertyName)
    Helper to raise PropertyChanged event for a given property.

  • void SetAvailableChannels(IRealtimeChannel[] channels)
    Sets the full, unfiltered list of channels. Triggers filtering and updates RealtimeChannels.

  • void SetSearchText(string searchText)
    Updates the internal search term and re-applies filtering. Channels whose ToString() representation contains the search term (case-insensitive, culture-sensitive) are included.

  • void SetRealtimeChannel(IRealtimeChannel channel)
    Publishes the selected channel via the RealtimeChannelSelectedEvent event.

  • 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 Prisms INavigationAware, 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 to BusyIndicatorChangeNotification.

  • 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 returns false. Indicates no unsaved changes (not implemented).


3. Invariants

  • RealtimeChannels always reflects the current filtered view of _allChannels after SetAvailableChannels or SetSearchText is called.
  • _searchTerm is used case-insensitively (via CultureInfo.CurrentCulture.CompareInfo) to filter channels by their ToString() representation.
  • IsBusy is updated synchronously on the publisher thread (due to ThreadOption.PublisherThread in subscription).
  • _allChannels is never null after SetAvailableChannels is called (though it may be an empty array).
  • RealtimeChannelSelectedEvent is published only when SetRealtimeChannel is invoked.
  • NotificationRequest is always raised with a Notification object containing a NotificationContentEventArgs (with empty Footer and FooterCommand fields) 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 RaiseNotification or control busy state via BusyIndicatorChangeNotification.
  • Any module that needs to respond to channel selection via RealtimeChannelSelectedEvent.
  • The view (IRealtimeChannelSelectView) binds to RealtimeChannels, 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 RealtimeChannelSelectedEvent to react to user selections.

5. Gotchas

  • ToString()-based filtering: Filtering relies on channel.ToString(), which may be implementation-specific (e.g., default type name or overridden). Ensure IRealtimeChannel implementations provide meaningful ToString() 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.
  • IsDirty always false: The IsDirty property is hardcoded to false. 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). Consider CultureInfo.InvariantCulture if consistent behavior across locales is required.
  • Thread safety: _allChannels and _searchTerm are not thread-safe. Filter() is called synchronously from SetAvailableChannels/SetSearchText, but if those are invoked from non-UI threads, race conditions may occur (though unlikely given Prism conventions).
  • Unused ConfirmationRequest: The ConfirmationRequest is declared but never used—potential tech debt or placeholder.
  • No command bindings: The #region Commands section is empty. UI interaction (e.g., channel selection) likely occurs via direct method calls from the view (e.g., SetRealtimeChannel), not Prism ICommand bindings.

None identified beyond the above.