Files
DP44/docs/ai/Common/DTS.Common/Base/View.md
2026-04-17 14:55:32 -04:00

39 lines
2.5 KiB
Markdown

---
source_files:
- Common/DTS.Common/Base/View/BaseWindow.cs
- Common/DTS.Common/Base/View/BaseView.cs
generated_at: "2026-04-17T16:07:30.415930+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "e97fdb071f87771a"
---
# View
### Purpose
This module defines base classes for views in a WPF/Prism application. `BaseWindow` and `BaseView` provide common properties (`IsDirty`, `HeaderInfo`) that delegate to their respective DataContext interfaces, enabling consistent dirty-tracking and header display across windows and user controls.
### Public Interface
**BaseWindow** (extends `Window`, implements `IBaseWindow`)
- `public bool IsDirty { get; }` — Returns `true` if `DataContext` implements `IBaseWindowModel` and `baseWindowModel.IsDirty` is `true`; otherwise returns `false`.
- `public string HeaderInfo { get; }` — Returns `iHeaderInfoProvider.HeaderInfo` if `DataContext` implements `IHeaderInfoProvider<string>`; otherwise returns `string.Empty`.
**BaseView** (extends `UserControl`, implements `IBaseView`)
- `public bool IsDirty { get; }` — Returns `true` if `DataContext` implements `IBaseViewModel` and `baseViewModel.IsDirty` is `true`; otherwise returns `false`.
- `public string HeaderInfo { get; }` — Returns `headerInfoProvider.HeaderInfo` if `DataContext` implements `IHeaderInfoProvider<string>`; otherwise returns `string.Empty`.
### Invariants
- Both `IsDirty` and `HeaderInfo` properties are read-only getters with no setters.
- If `DataContext` is `null`, both properties return default values (`false` for `IsDirty`, `string.Empty` for `HeaderInfo`).
- `BaseWindow.IsDirty` checks for `IBaseWindowModel`; `BaseView.IsDirty` checks for `IBaseViewModel` — these are different interfaces.
### Dependencies
- **Depends on**: `System.Windows` (`Window`), `System.Windows.Controls` (`UserControl`), `DTS.Common.Base` (interfaces `IBaseWindow`, `IBaseView`, `IBaseWindowModel`, `IBaseViewModel`, `IHeaderInfoProvider<string>` — inferred from usage).
- **Depended on by**: Unclear from source alone—likely used as base classes for specific views/windows throughout the application.
### Gotchas
- **Interface mismatch**: `BaseWindow.IsDirty` checks for `IBaseWindowModel` while `BaseView.IsDirty` checks for `IBaseViewModel`. If a DataContext implements the wrong interface for the container type, `IsDirty` will incorrectly return `false`.
- **Namespace directive**: Source includes `// ReSharper disable once CheckNamespace` suggesting the file location may not match the declared namespace `DTS.Common.Base`.
---