7.9 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T03:27:09.388583+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 10328346e97dc4f0 |
DTS.Common.Base Interfaces Documentation
1. Purpose
This module defines a foundational set of interfaces for implementing the MVVM (Model-View-ViewModel) pattern within the DTS application architecture. It establishes contracts for core components—IBaseModel, IBaseViewModel, IBaseWindowModel, IBaseView, IBaseWindow, and IBaseClass—that enforce standardized lifecycle management (initialization, activation, cleanup), state tracking (e.g., IsDirty, IsBusy, IsSaved), and data binding support via INotifyPropertyChanged. These interfaces decouple UI and business logic layers, enabling consistent behavior across views, viewmodels, and models while supporting asynchronous initialization and cleanup workflows.
2. Public Interface
Interfaces
-
IBaseClass- Definition:
public interface IBaseClass : IBasePropertyChanged { } - Behavior: Serves as a base interface for classes requiring property change notification. Currently acts as a marker interface extending
IBasePropertyChanged.
- Definition:
-
IViewModel- Definition:
public interface IViewModel { object Model { get; set; } } - Behavior: Provides a contract for viewmodels to expose and bind to a backing
Modelobject.
- Definition:
-
IBaseView- Definition:
public interface IBaseView { object DataContext { get; set; } } - Behavior: Defines a view contract with a
DataContextproperty for data binding (typically to a ViewModel).
- Definition:
-
IBaseWindow- Definition:
public interface IBaseWindow { object DataContext { get; set; } } - Behavior: Similar to
IBaseView, but intended for window-level UI components; exposesDataContextfor binding.
- Definition:
-
IBaseModel- Definition:
public interface IBaseModel : IBasePropertyChanged { bool IsSaved { get; } } - Behavior: Extends
IBasePropertyChangedand adds a read-onlyIsSavedproperty indicating whether the model has been persisted.
- Definition:
-
IBasePropertyChanged- Definition:
public interface IBasePropertyChanged : INotifyPropertyChanged { void OnPropertyChanged(string propertyName); } - Behavior: Extends
INotifyPropertyChangedand declares a requiredOnPropertyChangedmethod for raising change notifications.
- Definition:
-
IHeaderInfoProvider<T>- Definition:
public interface IHeaderInfoProvider<T> { T HeaderInfo { get; } } - Behavior: Provides a strongly-typed
HeaderInfoproperty for binding header metadata (e.g., title, subtitle) from XAML.
- Definition:
-
IBaseWindowModel- Definition:
public interface IBaseWindowModel : INotifyPropertyChanged { bool IsMenuIncluded { get; set; } bool IsNavigationIncluded { get; set; } bool IsBusy { get; set; } void Activated(); bool IsDirty { get; } void Cleanup(); Task CleanupAsync(); void Initialize(); void Initialize(object parameter); Task InitializeAsync(); Task InitializeAsync(object parameter); } - Behavior: Defines lifecycle and state management for window-level models. Includes properties for UI control visibility (
IsMenuIncluded,IsNavigationIncluded), busy state (IsBusy), dirty state (IsDirty), and methods for initialization/activation/cleanup (synchronous and asynchronous variants).
- Definition:
-
IBaseViewModel- Definition:
public interface IBaseViewModel : IBasePropertyChanged { bool IsMenuIncluded { get; set; } bool IsNavigationIncluded { get; set; } bool IsBusy { get; set; } void Activated(); bool IsDirty { get; } void Cleanup(); Task CleanupAsync(); void Initialize(); void Initialize(object parameter); void Initialize(object parameter, object model); Task InitializeAsync(); Task InitializeAsync(object parameter); } - Behavior: Defines lifecycle and state management for viewmodels. Extends
IBasePropertyChangedand includes all lifecycle methods ofIBaseWindowModel, plus an overloadedInitializemethod accepting bothparameterandmodelarguments.
- Definition:
3. Invariants
IBasePropertyChanged.OnPropertyChangedmust be called whenever a property value changes, passing the exact property name as a string.IsDirtyis read-only in bothIBaseViewModelandIBaseWindowModel; implementations must manage its state internally (e.g., via private setters or logic).IsSavedis read-only inIBaseModel; implementations must ensure it reflects the persistence state of the model.IsBusy,IsMenuIncluded, andIsNavigationIncludedare read-write inIBaseViewModelandIBaseWindowModel; they must be observable viaINotifyPropertyChanged.- Lifecycle methods (
Initialize,Cleanup,Activated) must be idempotent or explicitly documented for non-idempotency; the interface does not enforce ordering, but implementations should avoid re-initializing after cleanup. IBaseWindowModeldoes not extendIBasePropertyChanged(it directly implementsINotifyPropertyChanged), whileIBaseViewModelextendsIBasePropertyChanged. This is an intentional distinction in the design.
4. Dependencies
- Depends on:
System.ComponentModel(forINotifyPropertyChangedinIBasePropertyChanged,IBaseWindowModel, andIBaseViewModel).System.Threading.Tasks(forTaskinIBaseWindowModelandIBaseViewModel).
- Used by:
- Viewmodel and model implementations throughout the codebase (e.g., concrete classes implementing
IBaseViewModel,IBaseModel,IBaseWindowModel). - UI framework components (e.g., views/windows implementing
IBaseView/IBaseWindow) to bind to viewmodels/models. - XAML binding systems via
IHeaderInfoProvider<T>for header metadata.
- Viewmodel and model implementations throughout the codebase (e.g., concrete classes implementing
- No direct dependencies on other DTS modules are evident from the source files alone.
5. Gotchas
IBasePropertyChangeddeclaresOnPropertyChanged(string propertyName)but does not enforce null-safety or validation; callers must ensurepropertyNameis non-null and accurate (e.g., usingnameof()).IBaseWindowModelandIBaseViewModelshare overlapping members but are not related via inheritance (e.g.,IBaseWindowModeldoes not extendIBaseViewModel), which may lead to duplication or confusion.Initialize(object parameter, object model)inIBaseViewModelis absent inIBaseWindowModel—this asymmetry may cause inconsistencies if window models require model injection.IsDirtyhas no setter; implementations must define how dirty state is tracked (e.g., via property change handlers or explicitSetDirty()methods).- No default implementations are provided—consumers must implement all interface members, including boilerplate
INotifyPropertyChangedhandling. IBaseClassis currently empty beyond inheritance; its purpose is unclear without further context (possibly legacy or placeholder).- No guidance on thread affinity for lifecycle methods (e.g.,
InitializeAsync/CleanupAsync), which may lead to cross-thread UI violations if not handled carefully. IHeaderInfoProvider<T>is generic butTis unconstrained; implementations must ensureTis serializable or bindable if used in XAML.
None identified beyond the above.