5.3 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T03:28:18.795367+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 5f5625420afe05bf |
View
Documentation: DTS.Common.Base View Base Classes
1. Purpose
This module provides foundational WPF view base classes (BaseWindow and BaseView) that standardize common UI behavior across the application. Specifically, they expose two key properties—IsDirty and HeaderInfo—by delegating to corresponding interfaces implemented by the DataContext. This enables consistent dirty-state tracking and tab header rendering across different view types (windows and user controls) without requiring each view to reimplement the logic.
2. Public Interface
BaseWindow (inherits System.Windows.Window, implements IBaseWindow)
-
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. Returnsstring.EmptyifDataContextisnull.
BaseView (inherits System.Windows.Controls.UserControl, implements IBaseView)
-
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. Returnsstring.EmptyifDataContextisnull.
Note
: Both classes use read-only properties with no public setters. They are passive aggregators—they do not modify state or raise change notifications themselves.
3. Invariants
-
IsDirtybehavior:- Always returns
falseifDataContextisnull. - Always returns
falseifDataContextdoes not implement the expected interface (IBaseWindowModelforBaseWindow,IBaseViewModelforBaseView). - Otherwise, returns the exact value of
DataContext.IsDirty.
- Always returns
-
HeaderInfobehavior:- Always returns
string.EmptyifDataContextisnull. - Always returns
string.EmptyifDataContextdoes not implementIHeaderInfoProvider<string>. - Otherwise, returns the exact value of
DataContext.HeaderInfo.
- Always returns
-
No side effects: Neither property performs I/O, mutation, or triggers events. They are pure getters.
4. Dependencies
Internal Dependencies (from source):
System.Windows(WPF core types:Window,UserControl)DTS.Common.Basenamespace (same assembly/module):- Interfaces:
IBaseWindow,IBaseView,IBaseWindowModel,IBaseViewModel,IHeaderInfoProvider<string>
(These interfaces are referenced but not defined in the provided source—must be defined elsewhere.)
- Interfaces:
External Dependencies:
- WPF runtime (
PresentationFramework,WindowsBase) - ReSharper attributes (
// ReSharper disable once CheckNamespacesuggests use of ReSharper for namespace conventions, but no runtime dependency)
Inferred Consumers:
- Any WPF view that inherits from
BaseWindoworBaseView. - UI layers (e.g.,
TabControl) that bind toHeaderInfoandIsDirtyon views. - ViewModels/Models implementing
IBaseWindowModel,IBaseViewModel, orIHeaderInfoProvider<string>.
5. Gotchas
-
Interface mismatch risk:
BaseWindowexpectsIBaseWindowModelforIsDirty, whileBaseViewexpectsIBaseViewModel. Using the wrong model type (e.g.,IBaseViewModelin aBaseWindow) will causeIsDirtyto always returnfalse, even if the model is dirty. -
No change notification:
These properties do not raiseINotifyPropertyChangedevents. If the underlyingIsDirtyorHeaderInfovalues change, the view will not automatically update unless theDataContextitself raises property change notifications and the binding is set up to requery (e.g., viaBindingExpression.UpdateSource()orMode=OneWaywithINotifyPropertyChangedon the model). -
string.Emptyvsnull:
HeaderInforeturnsstring.Empty(notnull) when no provider is found—this avoids XAML binding errors but may require explicit handling ifnullis semantically meaningful. -
No validation or error handling:
IfDataContext.HeaderInfothrows an exception, it will propagate unhandled. Similarly, ifDataContextis a disposed or partially initialized object, behavior is undefined. -
Ambiguous naming:
The XML comments say "bound object data data" (double "data")—suggests legacy copy-paste or incomplete editing. Not a functional issue, but indicates possible tech debt. -
No explicit interface implementation:
Properties are public on the view classes, not explicit interface implementations. This may cause confusion ifIBaseWindow/IBaseVieware intended to be used as contracts.
None identified from source alone for additional gotchas beyond the above.