8.0 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T02:50:59.182890+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | cd583516ecde421b |
Interface
Documentation: DTS.Common.Base Interface Layer
1. Purpose
This module defines a foundational set of interfaces for implementing the Model-View-ViewModel (MVVM) pattern within the DTS codebase. It establishes contract-based abstractions for core UI and data entities—IBaseModel, IBaseViewModel, IBaseWindowModel, IBaseView, IBaseWindow, and supporting interfaces like IBasePropertyChanged and IHeaderInfoProvider<T>—to enforce consistency, lifecycle management, and property change notification across the application. These interfaces decouple UI components (Views/Windows) from their backing logic (ViewModels/Models), enabling testability, reuse, and standardized behavior for state tracking (IsDirty, IsBusy, IsSaved), initialization, and cleanup.
2. Public Interface
Interfaces (all in DTS.Common.Base namespace)
| Interface | Signature | Description |
|---|---|---|
IBaseClass |
public interface IBaseClass : IBasePropertyChanged { } |
Marker interface extending IBasePropertyChanged. Used as a base contract for classes requiring property change notification. |
IBasePropertyChanged |
public interface IBasePropertyChanged : INotifyPropertyChanged { void OnPropertyChanged(string propertyName); } |
Extends INotifyPropertyChanged with a required OnPropertyChanged(string) method. Note: No default implementation is provided. |
IBaseModel |
public interface IBaseModel : IBasePropertyChanged { bool IsSaved { get; } } |
Base interface for domain models. Guarantees IsSaved read-only state (e.g., whether the model has unsaved changes). |
IBaseViewModel |
public interface IBaseViewModel : IBasePropertyChanged { ... } |
Base interface for ViewModels. Includes lifecycle methods (Initialize, Activated, Cleanup, CleanupAsync, InitializeAsync) and state properties (IsMenuIncluded, IsNavigationIncluded, IsBusy, IsDirty). Supports multiple Initialize overloads (with/without parameter, and with parameter + model). |
IBaseWindowModel |
public interface IBaseWindowModel : INotifyPropertyChanged { ... } |
Base interface for Window-level ViewModels. Mirrors IBaseViewModel but does not inherit IBasePropertyChanged (directly implements INotifyPropertyChanged). Includes identical lifecycle/state members. |
IViewModel |
public interface IViewModel { object Model { get; set; } } |
Minimal interface for ViewModels to expose their backing Model. Does not enforce lifecycle or state properties. |
IBaseView |
public interface IBaseView { object DataContext { get; set; } } |
Base interface for Views (e.g., UserControls). Declares DataContext for binding to a ViewModel. |
IBaseWindow |
public interface IBaseWindow { object DataContext { get; set; } } |
Base interface for Window classes. Declares DataContext for binding to a Window-level ViewModel. |
IHeaderInfoProvider<T> |
public interface IHeaderInfoProvider<T> { T HeaderInfo { get; } } |
Generic interface for objects that expose a HeaderInfo (e.g., for XAML binding to UI headers). Type parameter T specifies the HeaderInfo type. |
Lifecycle Method Overloads Summary
All Initialize/Cleanup methods are defined in both IBaseViewModel and IBaseWindowModel:
void Initialize();void Initialize(object parameter);void Initialize(object parameter, object model);(only inIBaseViewModel)Task InitializeAsync();Task InitializeAsync(object parameter);void Activated();void Cleanup();Task CleanupAsync();
State Properties
Shared across IBaseViewModel and IBaseWindowModel:
bool IsMenuIncluded { get; set; }bool IsNavigationIncluded { get; set; }bool IsBusy { get; set; }bool IsDirty { get; }(read-only)bool IsSaved { get; }(only inIBaseModel)
3. Invariants
- Property Change Notification: Any class implementing
IBasePropertyChanged(includingIBaseClass,IBaseModel,IBaseViewModel) must raisePropertyChangedviaOnPropertyChanged(string propertyName). The interface does not enforce thread-safety or throttling—consumers must handle this. IsDirtyvsIsSaved:IsDirty(inIBaseViewModel/IBaseWindowModel) indicates whether the ViewModel has unsaved changes relative to its initialization state.IsSaved(inIBaseModel) indicates whether the underlying Model has been persisted.
These are orthogonal: a model can beIsSaved=truebutIsDirty=trueif the ViewModel has made new changes since the last save.
- Lifecycle Order:
Initialize/InitializeAsync→Activated→ (user interaction) →Cleanup/CleanupAsync.
InitializeAsyncandCleanupAsyncare asynchronous; callers must await them to ensure completion before proceeding. IHeaderInfoProvider<T>: TheHeaderInfoproperty is read-only (getonly). Implementations must ensureHeaderInfois non-null (or handle null gracefully) for XAML binding.
4. Dependencies
Dependencies of this module:
System.ComponentModel: Required forINotifyPropertyChanged(used inIBasePropertyChanged,IBaseWindowModel,IBaseViewModel).System.Threading.Tasks: Required forTaskreturn types inIBaseViewModelandIBaseWindowModel.
Dependencies on this module (inferred from naming conventions and usage patterns):
- UI Layer: Views (e.g., WPF
Window,UserControl) likely implementIBaseView/IBaseWindowand bindDataContextto ViewModels implementingIBaseViewModel/IBaseWindowModel. - ViewModel Layer: Concrete ViewModels inherit from base classes implementing
IBaseViewModelorIBaseWindowModel. - Model Layer: Domain models likely implement
IBaseModel. - Header Binding: UI components (e.g., headers, toolbars) consume types implementing
IHeaderInfoProvider<T>.
No internal dependencies within this module (interfaces are self-contained).
5. Gotchas
IBaseWindowModeldoes not inheritIBasePropertyChanged: It directly implementsINotifyPropertyChanged. This is inconsistent withIBaseViewModel(which inheritsIBasePropertyChanged). Developers may mistakenly assume both share the same base contract.OnPropertyChangedsignature lacks default parameter: The interface definesvoid OnPropertyChanged(string propertyName);without a default value (commented-out alternatives exist in source but are not part of the contract). Implementers must pass a non-null property name (or risk silent failures).IsDirtyis read-only: Its value must be computed internally (e.g., viaSetPropertylogic or manual tracking). No setter is exposed, so external state changes (e.g., after save) require updating via internal logic.Initialize(object parameter, object model)isIBaseViewModel-only:IBaseWindowModellacks this overload. Using it in a Window-level ViewModel may cause ambiguity or require custom implementation.- No default implementations: These are interfaces only. Concrete behavior (e.g.,
SetProperty,IsDirtytracking) must be provided by base classes or implementations (not documented here). - Namespace quirk: All interfaces use
DTS.Common.Basedespite being inDTS.CommonCorepaths. This may cause confusion if namespace resolution is expected to match folder structure.
None identified from source alone.