This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,145 @@
---
source_files:
- Common/DTS.Common/Base/Classes/BaseUserControl.cs
- Common/DTS.Common/Base/Classes/BasePropertyChanged.cs
- Common/DTS.Common/Base/Classes/DisplayResourceAttribute.cs
- Common/DTS.Common/Base/Classes/DescriptionResourceAttribute.cs
- Common/DTS.Common/Base/Classes/DynamicTypeDescriptor.cs
generated_at: "2026-04-17T15:36:38.292547+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "584aa4e7cd1ac4ca"
---
# Documentation: DTS.Common.Base Classes
## 1. Purpose
This module provides foundational infrastructure for the DTS codebase, including:
- **Property change notification base classes** (`BasePropertyChanged`, `BaseUserControl`) that implement the `INotifyPropertyChanged` pattern for data binding scenarios in both UI and non-UI contexts.
- **Localizable attribute classes** (`DisplayResourceAttribute`, `DescriptionResourceAttribute`) that enable runtime resource lookup for property display names and descriptions, supporting internationalization.
- **Dynamic type introspection** (`DynamicTypeDescriptor`) that enables runtime modification of type metadata, allowing dynamic addition/removal of properties and modification of attributes for scenarios like PropertyGrid customization.
---
## 2. Public Interface
### BaseUserControl (abstract class)
**Namespace:** `DTS.Common.Base.Classes`
**Inherits:** `System.Windows.Controls.UserControl`
| Member | Signature | Description |
|--------|-----------|-------------|
| `PropertyChanged` | `event PropertyChangedEventHandler PropertyChanged` | Event raised when a property value changes. |
| `SetProperty<T>` | `protected bool SetProperty<T>(ref T storage, T value, String propertyName = null)` | Sets the field value if different; returns `true` if changed, `false` if values are equal. Raises `PropertyChanged` on change. |
| `OnPropertyChanged` | `protected void OnPropertyChanged(string propertyName = null)` | Raises the `PropertyChanged` event. |
---
### BasePropertyChanged (abstract class)
**Namespace:** `DTS.Common.Base`
**Implements:** `IBasePropertyChanged` (interface definition not provided in source)
| Member | Signature | Description |
|--------|-----------|-------------|
| `PropertyChanged` | `public virtual event PropertyChangedEventHandler PropertyChanged` | Virtual event for property change notification. |
| `SetProperty<T>` | `public bool SetProperty<T>(ref T storage, T value, String propertyName = null)` | Sets the field value if different; returns `true` if changed. Public visibility (unlike `BaseUserControl`). |
| `OnPropertyChanged` | `public virtual void OnPropertyChanged(string propertyName = null)` | Virtual method to raise `PropertyChanged` event. |
---
### DisplayResourceAttribute
**Namespace:** `DTS.Common.Base.Classes`
**Inherits:** `System.ComponentModel.DisplayNameAttribute`
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `public DisplayResourceAttribute(string resourceId)` | Initializes with a resource identifier to look up. |
| `DisplayName` | `public override string DisplayName` | Looks up the localized string via `Strings.Strings.ResourceManager.GetString(_resourceId)`. Returns `"##ResourceNotFound##" + _resourceId` if not found. |
---
### DescriptionResourceAttribute
**Namespace:** `DTS.Common.Base.Classes`
**Inherits:** `System.ComponentModel.DescriptionAttribute`
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `public DescriptionResourceAttribute(string resourceId)` | Initializes with a resource identifier to look up. |
| `Description` | `public override string Description` | Looks up the localized string via `Strings.Strings.ResourceManager.GetString(_resourceId)`. Returns `"##DescriptionNotFound##" + _resourceId` if not found. |
---
### DynamicTypeDescriptor (sealed class)
**Namespace:** `DTS.Common.Base.Classes`
**Implements:** `System.ComponentModel.ICustomTypeDescriptor`, `System.ComponentModel.INotifyPropertyChanged`
#### Constructors
| Signature | Description |
|-----------|-------------|
| `public DynamicTypeDescriptor(Type type)` | Creates a descriptor for the specified type, extracting properties, attributes, editors, and events via `TypeDescriptor`. Throws `ArgumentNullException` if `type` is null. |
#### Properties
| Name | Type | Description |
|------|------|-------------|
| `Component` | `object` | The component instance this descriptor wraps (set via `FromComponent`). |
| `ClassName` | `string` | Optional override for class name. |
| `ComponentName` | `string` | Optional override for component name. |
| `OriginalProperties` | `PropertyDescriptorCollection` | Properties from the original type via `TypeDescriptor.GetProperties(type)`. |
| `Properties` | `PropertyDescriptorCollection` | Modifiable collection of properties (excludes non-browsable by default). |
#### Public Methods
| Signature | Description |
|-----------|-------------|
| `public T GetPropertyValue<T>(string name, T defaultValue)` | Gets a property value by name, returning `defaultValue` if not found or on conversion failure. |
| `public void SetPropertyValue(string name, object value)` | Sets a property value by name. |
| `public PropertyDescriptor AddProperty(Type type, string name, object value, string displayName, string description, string category, bool hasDefaultValue, object defaultValue, bool readOnly)` | Adds a new dynamic property. |
| `public PropertyDescriptor AddProperty(..., Type uiTypeEditor)` | Adds a new dynamic property with a UI type editor. |
| `public void AddProperty(PropertyDescriptor property)` | Adds an existing `PropertyDescriptor` to the `Properties` collection. |
| `public void RemoveProperty(string name)` | Removes all properties matching the given name. |
| `public DynamicTypeDescriptor FromComponent(object component)` | Creates a new `DynamicTypeDescriptor` bound to a specific component instance. Throws if component type is not assignable to `_type`. |
#### Events
| Member | Description |
|--------|-------------|
| `public event PropertyChangedEventHandler PropertyChanged` | Raised when a property value changes via `DynamicProperty.SetValue`. |
---
### DynamicTypeDescriptor.DynamicProperty (sealed class)
**Namespace:** `DTS.Common.Base.Classes.DynamicTypeDescriptor`
**Inherits:** `System.ComponentModel.PropertyDescriptor`
**Implements:** `System.ComponentModel.INotifyPropertyChanged`
#### Properties
| Name | Description |
|------|-------------|
| `Value` | The property value (used when no existing `PropertyDescriptor` is wrapped). |
| `AttributesList` | `IList<Attribute>` - modifiable list of attributes. |
| `IsBrowsable`, `IsReadOnly`, `DisplayName`, `Description`, `Category` | Overridable metadata values. |
#### Methods
| Signature | Description |
|-----------|-------------|
| `public void RemoveAttributesOfType<T>()` | Removes all attributes of type `T` from the property. |
| `public void SetBrowsable(bool browsable)` | Overrides the `IsBrowsable` value. |
| `public void SetIsReadOnly(bool readOnly)` | Overrides the `IsReadOnly` value. |
| `public void SetDisplayName(string displayName)` | Overrides the `DisplayName` value. |
| `public void SetDescription(string description)` | Overrides the `Description` value. |
| `public void SetCategory(string category)` | Overrides the `Category` value. |
| `public void SetEditor(Type editorBaseType, object obj)` | Sets or removes a custom editor for this property. |
---
## 3. Invariants
### BaseUserControl / BasePropertyChanged
- `SetProperty<T>` uses `Equals(storage, value)` for equality comparison; if values are equal, no event is raised and the method returns `false`.
- `propertyName` parameter defaults to `null`; caller is responsible for passing the correct property name (no `CallerMemberName` usage observed).
### DisplayResourceAttribute / DescriptionResourceAttribute
- The `_resourceId` field is stored but never validated for null/empty at construction time.
- Resource lookup is performed on every access to `DisplayName`/`Description` (no caching observed).
- Failure to find a resource results in a fallback string prefixed with `##ResourceNotFound##` or `##DescriptionNotFound##`.
### Dynamic

View File

@@ -0,0 +1,88 @@
---
source_files:
- Common/DTS.Common/Base/Interface/IBaseClass.cs
- Common/DTS.Common/Base/Interface/IViewModel.cs
- Common/DTS.Common/Base/Interface/IBaseView.cs
- Common/DTS.Common/Base/Interface/IBaseWindow.cs
- Common/DTS.Common/Base/Interface/IBaseModel.cs
- Common/DTS.Common/Base/Interface/IBasePropertyChanged.cs
- Common/DTS.Common/Base/Interface/IHeaderInfoProvider.cs
- Common/DTS.Common/Base/Interface/IBaseWindowModel.cs
- Common/DTS.Common/Base/Interface/IBaseViewModel.cs
generated_at: "2026-04-17T16:04:27.061097+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "9843a728bff22f95"
---
# Interface
### Purpose
This module defines the fundamental contracts for the MVVM (Model-View-ViewModel) architecture used within the `DTS.CommonCore` library. It establishes the base interfaces for property change notification, data models, views, and view models, ensuring a consistent approach to data binding and lifecycle management across the system.
### Public Interface
* **`interface IBasePropertyChanged : INotifyPropertyChanged`**
* Extends `INotifyPropertyChanged` to add a manual notification method.
* `void OnPropertyChanged(string propertyName)`: Raises the `PropertyChanged` event for the specified property name.
* **`interface IBaseClass : IBasePropertyChanged`**
* A marker interface for base classes that support property change notification. It defines no additional members.
* **`interface IBaseModel : IBasePropertyChanged`**
* Represents a data model with a persistent state tracking capability.
* `bool IsSaved { get; }`: Gets a value indicating whether the model is saved.
* **`interface IViewModel`**
* Defines a basic view model wrapper around a model object.
* `object Model { get; set; }`: Gets or sets the underlying data model object.
* **`interface IBaseView`**
* Defines a view element capable of data binding.
* `object DataContext { get; set; }`: Gets or sets the data context for the view.
* **`interface IBaseWindow`**
* Defines a window element capable of data binding.
* `object DataContext { get; set; }`: Gets or sets the data context for the window.
* **`interface IHeaderInfoProvider<T>`**
* Provides a mechanism for classes to expose header information for XAML binding.
* `T HeaderInfo { get; }`: Gets the header information.
* **`interface IBaseViewModel : IBasePropertyChanged`**
* Defines the lifecycle and state properties for a standard view model.
* `bool IsMenuIncluded { get; set; }`: Gets or sets whether a menu is included.
* `bool IsNavigationIncluded { get; set; }`: Gets or sets whether navigation is included.
* `bool IsBusy { get; set; }`: Gets or sets the busy state.
* `bool IsDirty { get; }`: Gets whether the view model has unsaved changes.
* `void Activated()`: Called when the view model is activated.
* `void Cleanup()`: Synchronously cleans up resources.
* `Task CleanupAsync()`: Asynchronously cleans up resources.
* `void Initialize()`: Initializes the view model.
* `void Initialize(object parameter)`: Initializes the view model with a parameter.
* `void Initialize(object parameter, object model)`: Initializes the view model with a parameter and a model.
* `Task InitializeAsync()`: Asynchronously initializes the view model.
* `Task InitializeAsync(object parameter)`: Asynchronously initializes the view model with a parameter.
* **`interface IBaseWindowModel : INotifyPropertyChanged`**
* Defines the lifecycle and state properties for a window-level model.
* `bool IsMenuIncluded { get; set; }`
* `bool IsNavigationIncluded { get; set; }`
* `bool IsBusy { get; set; }`
* `bool IsDirty { get; }`
* `void Activated()`
* `void Cleanup()`
* `Task CleanupAsync()`
* `void Initialize()`
* `void Initialize(object parameter)`
* `Task InitializeAsync()`
* `Task InitializeAsync(object parameter)`
### Invariants
* `IBaseView.DataContext` and `IBaseWindow.DataContext` must accept an object that is typically an implementation of `IBaseViewModel` or `IBaseWindowModel`.
* `IBaseViewModel.Initialize` overloads suggest that initialization logic must handle cases with zero, one, or two parameters.
* `IBaseWindowModel` inherits from `INotifyPropertyChanged` directly, whereas `IBaseViewModel` inherits from `IBasePropertyChanged`.
### Dependencies
* **Dependencies:** `System.ComponentModel`, `System.Threading.Tasks`.
* **Dep

View File

@@ -0,0 +1,39 @@
---
source_files:
- Common/DTS.Common/Base/Model/BaseModel.cs
generated_at: "2026-04-17T16:10:18.439141+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "3b859bff5a41827f"
---
# Model
### Purpose
This module provides the abstract `BaseModel<TModel>` class, which serves as a foundational base class for creating model wrapper objects in the DTS system. It establishes a pattern for wrapping domain model objects with additional infrastructure (property change notification and persistence tracking) while maintaining type safety through generics.
### Public Interface
- **`BaseModel<TModel>`** (abstract class)
- Inherits from: `BasePropertyChanged`, implements `IBaseModel`
- Generic constraint: `TModel : class`
- **`TModel Model { get; set; }`** - Gets or sets the wrapped model object.
- **`bool IsSaved { get; }`** - Gets a value indicating whether the model has been saved. Has a private setter; no public method exists to set this to true.
- **`BaseModel()`** - Public parameterless constructor. Creates a new instance of the base class.
### Invariants
- `TModel` must always be a reference type (class constraint).
- `IsSaved` is initialized to `false` (default bool value) and can only be modified within the class itself.
### Dependencies
- **Depends on**: `BasePropertyChanged` (base class providing property change notification), `IBaseModel` (interface contract).
- **Depended on by**: Unknown from this source alone, but designed as a base class for model wrappers throughout the system.
### Gotchas
- The `IsSaved` property has a private setter but no method in this class ever sets it to `true`. Subclasses or external code cannot modify it, suggesting either incomplete implementation or that reflection/serialization is expected to set it.
- The class is abstract but has a public constructor (suppressed ReSharper warning indicates this is intentional, possibly for serialization or reflection scenarios).
---

View File

@@ -0,0 +1,39 @@
---
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`.
---

View File

@@ -0,0 +1,63 @@
---
source_files:
- Common/DTS.Common/Base/ViewModel/ViewModelBase.cs
- Common/DTS.Common/Base/ViewModel/BaseViewModel.cs
generated_at: "2026-04-17T15:41:12.237629+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "4dad13537847aaee"
---
# Documentation: DTS.Common.Base ViewModel Classes
## 1. Purpose
This module provides two abstract base classes for the Model-View-ViewModel (MVVM) pattern within a WPF application. `ViewModelBase<T>` serves as a foundational class for ViewModels that manage their own commands and actions, inheriting from `DependencyObject` to support WPF dependency properties. `BaseViewModel<TModel>` provides a more feature-rich base class with Prism integration, offering built-in support for event aggregation, dependency injection via Unity, interaction requests, and lifecycle management (initialization, activation, cleanup). Both classes implement property change notification and track busy/dirty states for UI binding.
---
## 2. Public Interface
### ViewModelBase<T>
**Type Parameters:** `T` - The type of the Model object.
| Member | Signature | Description |
|--------|-----------|-------------|
| `Model` | `public object Model { get; set; }` | Gets or sets the Model object. Note: This is typed as `object`, not `T`. |
| `IsBusy` | `public bool IsBusy { get; protected set; }` | Indicates whether the object is executing an asynchronous process. |
| `IsDirty` | `public virtual bool IsDirty { get; protected set; }` | Indicates whether the Model has been changed. |
| `ErrorOccurred` | `public virtual event EventHandler<ErrorEventArgs> ErrorOccurred` | Event raised when an error occurs during processing. |
| `PropertyChanged` | `public virtual event PropertyChangedEventHandler PropertyChanged` | Event raised when a property changes. |
**Protected Abstract Methods (must be implemented by derived classes):**
| Method | Signature | Description |
|--------|-----------|-------------|
| `InitializeAsync` | `protected abstract Task<T> InitializeAsync()` | Implement async initialization; the result sets the Model property. |
| `DoRefresh` | `protected abstract void DoRefresh(Func<T> factoryMethod)` | Creates or retrieves a new Model instance via a static factory method. |
| `OnError` | `protected abstract void OnError(Exception error)` | Raises the `ErrorOccurred` event when an error occurs. |
| `OnModelChanged` | `protected abstract void OnModelChanged(T oldValue, T newValue)` | Invoked when the Model changes; allows unhooking/hooking event handlers. |
| `OnPropertyChanged` | `protected abstract void OnPropertyChanged(string propertyName)` | Raises the `PropertyChanged` event. |
---
### BaseViewModel<TModel>
**Type Parameters:** `TModel` - The type of the Model object (must be a reference type: `where TModel : class`).
**Constructors:**
| Constructor | Signature | Description |
|-------------|-----------|-------------|
| Default | `protected BaseViewModel()` | Parameterless constructor. |
| DI Constructor | `protected BaseViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)` | Initializes aggregator, container, and calls `CreateCommands()`. Note: `regionManager` parameter is unused. |
**Properties:**
| Property | Signature | Description |
|----------|-----------|-------------|
| `Aggregator` | `protected IEventAggregator Aggregator { get; private set; }` | Prism event aggregator for pub/sub messaging. |
| `Container` | `protected IUnityContainer Container { get; private set; }` | Unity DI container. |
| `Model` | `public TModel Model { get; set; }` | The strongly-typed model object. |
| `Confirmation