Files
DP44/enriched-qwen3-coder-next/Common/DTS.Common.Property.md

109 lines
6.5 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common.Property/PropertyModule.cs
generated_at: "2026-04-16T14:12:34.427071+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "5ade2343bf1c7a50"
---
# Documentation: DTS.Common.Property.PropertyModule
## 1. Purpose
This module serves as the Prism module initializer for the Property component within the DTS application. It registers the Property view and view-model with the Unity dependency injection container, enabling the Property UI component to be dynamically loaded and displayed in the application's modular architecture. The module also defines assembly-level metadata attributes (`PropertiesNameAttribute` and `PropertiesImageAttribute`) that provide display information (name, image, region, group) used by the main shell to present this module as an available component to users.
---
## 2. Public Interface
### `PropertyModule` Class
**Signature:**
```csharp
[Export(typeof(IModule))]
[Module(ModuleName = "Property")]
public class PropertyModule : IModule
```
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `public PropertyModule(IUnityContainer unityContainer)` | Accepts an injected Unity container reference for DI registration. |
| `Initialize()` | `public void Initialize()` | Registers `IPropertyView``PropertyView` and `IPropertyViewModel``PropertyViewModel` with the Unity container (transient lifetime, not singleton despite the comment). |
### `PropertiesNameAttribute` Class
**Signature:**
```csharp
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class PropertiesNameAttribute : TextAttribute
```
| Member | Signature | Description |
|--------|-----------|-------------|
| Default Constructor | `public PropertiesNameAttribute()` | Initializes with no parameters. |
| Parameterized Constructor | `public PropertiesNameAttribute(string s)` | Accepts a string parameter (which is ignored). |
| `AssemblyName` | `public override string AssemblyName { get; }` | Returns hardcoded value `"PropertiesAsssembly"`. |
| `GetAttributeType()` | `public override Type GetAttributeType()` | Returns `typeof(TextAttribute)`. |
| `GetAssemblyName()` | `public override string GetAssemblyName()` | Returns the `AssemblyName` property value. |
### `PropertiesImageAttribute` Class
**Signature:**
```csharp
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class PropertiesImageAttribute : ImageAttribute
```
| Member | Signature | Description |
|--------|-----------|-------------|
| Default Constructor | `public PropertiesImageAttribute()` | Initializes with no parameters. |
| Parameterized Constructor | `public PropertiesImageAttribute(string s)` | Accepts a string parameter (which is ignored). |
| `AssemblyImage` | `public override BitmapImage AssemblyImage { get; }` | Retrieves image via `AssemblyInfo.GetImage(AssemblyNames.Property.ToString())`. |
| `AssemblyName` | `public override string AssemblyName { get; }` | Returns `AssemblyNames.Property.ToString()`. |
| `AssemblyGroup` | `public override string AssemblyGroup { get; }` | Returns `eAssemblyGroups.Viewer.ToString()`. |
| `AssemblyRegion` | `public override eAssemblyRegion AssemblyRegion { get; }` | Returns `eAssemblyRegion.PropertyRegion`. |
| `GetAttributeType()` | `public override Type GetAttributeType()` | Returns `typeof(ImageAttribute)`. |
| `GetAssemblyImage()` | `public override BitmapImage GetAssemblyImage()` | Returns the `AssemblyImage` property. |
| `GetAssemblyName()` | `public override string GetAssemblyName()` | Returns the `AssemblyName` property. |
| `GetAssemblyRegion()` | `public override eAssemblyRegion GetAssemblyRegion()` | Returns the `AssemblyRegion` property. |
| `GetAssemblyGroup()` | `public override string GetAssemblyGroup()` | Returns the `AssemblyGroup` property. |
---
## 3. Invariants
- **Single Instance per Assembly**: Both `PropertiesNameAttribute` and `PropertiesImageAttribute` are applied at assembly level with `AllowMultiple = false`, ensuring only one instance of each exists per assembly.
- **Module Name**: The module is registered with the fixed name `"Property"` via the `[Module]` attribute.
- **Registration Lifetime**: The `RegisterType` calls in `Initialize()` register types with transient (not singleton) lifetime. The code comment claims singleton registration, but `RegisterType` without a `ContainerControlledLifetimeManager` creates new instances per resolve.
- **Attribute Parameter Ignored**: Both attribute classes accept a `string s` parameter in their constructors, but this value is never used.
---
## 4. Dependencies
### This Module Depends On:
- `System` - Core .NET framework
- `System.ComponentModel.Composition` - MEF for module export
- `System.Windows.Media.Imaging` - `BitmapImage` for assembly image
- `Microsoft.Practices.Prism.Modularity` - `IModule` interface and `[Module]` attribute
- `Microsoft.Practices.Unity` - `IUnityContainer` for DI
- `DTS.Common.Interface` - Defines `IPropertyView`, `IPropertyViewModel`, `TextAttribute`, `ImageAttribute`, `AssemblyNames`, `eAssemblyGroups`, `eAssemblyRegion`, `AssemblyInfo` (inferred from usage)
### What Depends On This Module:
- The main application shell (loads this module via Prism's module catalog)
- The main UI (uses assembly attributes to display module metadata)
---
## 5. Gotchas
1. **Typo in Assembly Name**: `PropertiesNameAttribute._assemblyName` is hardcoded to `"PropertiesAsssembly"` (note the triple 's': "Asss" instead of "Asse"). This may cause display or lookup issues.
2. **Misleading XML Comment**: The constructor's XML documentation references `<see cref="PropertiesModule"/>`, but the actual class name is `PropertyModule` (singular "Property", not "Properties").
3. **Misleading Registration Comment**: The comment in `Initialize()` states "Register View & View-Model... as a singleton", but `RegisterType<TFrom, TTo>()` without a lifetime manager registers types as transient, not singleton. To achieve singleton behavior, `RegisterType<TFrom, TTo>(new ContainerControlledLifetimeManager())` would be required.
4. **Property Getters with Side Effects**: The `AssemblyImage` property getter in `PropertiesImageAttribute` has a side effect—it assigns to the private `_img` field. This violates typical property getter conventions and could cause unexpected behavior if the property is accessed multiple times.
5. **Ignored Constructor Parameters**: Both attribute classes have constructors accepting a `string s` parameter that is completely ignored. This is confusing and potentially dead code.