5.4 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T02:51:29.370197+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | e8beceb1bd7a7dfb |
View
Documentation: DTS.Common.Base View Base Classes
1. Purpose
This module provides foundational WPF view base classes (BaseWindow and BaseView) that standardize behavior for UI components in the application. These classes abstract common concerns—specifically, determining whether the underlying data model has unsaved changes (IsDirty) and retrieving a display-friendly header string (HeaderInfo) for tabbed interfaces—by delegating to interfaces implemented by the DataContext. They serve as reusable base classes to enforce consistency across views and reduce boilerplate in derived window and user control implementations.
2. Public Interface
BaseWindow
-
Namespace:
DTS.Common.Base -
Inherits:
System.Windows.Window, implementsIBaseWindow(interface not shown in source; assumed to declareIsDirtyandHeaderInfomembers). -
public bool IsDirty { get; }
Returnstrueif theDataContextimplementsIBaseWindowModeland itsIsDirtyproperty istrue; otherwisefalse. ReturnsfalseifDataContextisnullor does not implementIBaseWindowModel. -
public string HeaderInfo { get; }
Returns theHeaderInfostring from theDataContextif it implementsIHeaderInfoProvider<string>; otherwise returnsstring.Empty.
BaseView
-
Namespace:
DTS.Common.Base -
Inherits:
System.Windows.Controls.UserControl, implementsIBaseView(interface not shown in source; assumed to declareIsDirtyandHeaderInfomembers). -
public bool IsDirty { get; }
Returnstrueif theDataContextimplementsIBaseViewModeland itsIsDirtyproperty istrue; otherwisefalse. ReturnsfalseifDataContextisnullor does not implementIBaseViewModel. -
public string HeaderInfo { get; }
Returns theHeaderInfostring from theDataContextif it implementsIHeaderInfoProvider<string>; otherwise returnsstring.Empty.
Note
: Both classes use identical logic for
HeaderInfo, but differ in the interface they check forIsDirty:IBaseWindowModel(forBaseWindow) vs.IBaseViewModel(forBaseView). The interfacesIBaseWindowModelandIBaseViewModelare not defined in the provided source.
3. Invariants
IsDirtyalways returnsfalseifDataContextisnull.IsDirtyonly reads from theDataContext; it does not modify state.HeaderInfoalways returns a non-null string (string.Emptyif no provider is available).- Both classes assume
DataContextis set beforeIsDirtyorHeaderInfois accessed (though no explicit ordering requirement is enforced). - The
IsDirtylogic is passive: it reflects the state of theDataContextbut does not trigger updates or subscriptions.
4. Dependencies
External Dependencies (from source):
System.Windows(WPF framework) — required forWindowandUserControlbase types.- Interfaces
IBaseWindowModel,IBaseViewModel, andIHeaderInfoProvider<string>— referenced but not defined in the provided source. Their definitions must exist elsewhere in the codebase (likely inDTS.Common.Baseor a related namespace).
Internal Dependencies:
- Consumers: Any WPF window or user control inheriting from
BaseWindoworBaseView(e.g., customMainWindow : BaseWindow). - Required by
DataContext:- For
BaseWindow:DataContextmust implementIBaseWindowModelto participate inIsDirtyreporting. - For
BaseView:DataContextmust implementIBaseViewModelto participate inIsDirtyreporting. - For both:
DataContextmust implementIHeaderInfoProvider<string>to provide a non-emptyHeaderInfo.
- For
5. Gotchas
- Interface mismatch risk:
BaseWindowchecks forIBaseWindowModel, whileBaseViewchecks forIBaseViewModel. If a shared model implements both (or neither), behavior may be inconsistent or misleading. - No fallback or logging: If
DataContextis misconfigured (e.g., implementsIHeaderInfoProvider<string>but returnsnull),HeaderInfowill still returnstring.Empty—no warning or exception occurs. - No change notification:
IsDirtyis a synchronous read-only property. It does not raiseINotifyPropertyChangedevents, so UI bindings toIsDirty(e.g., for tab indicators) may not update automatically when the underlying model changes. Consumers must ensureDataContextraisesPropertyChangedforIsDirtyand re-evaluates the property (e.g., viaOnPropertyChanged(nameof(IsDirty))in the view model). - Ambiguous naming: The XML comments refer to “IBaseWindowModel” and “IBaseViewModel” but do not clarify their relationship or whether they overlap. Without seeing their definitions, it is unclear if a single
DataContextcould implement both. - No null-safety for
HeaderInfo: IfIHeaderInfoProvider<string>.HeaderInforeturnsnull, the property will returnnull(notstring.Empty). The code only guards against missing interface implementation, not interface contract violations.
None identified from source alone for additional issues beyond those inferred from the logic and naming patterns.