Files
2026-04-17 14:55:32 -04:00

7.2 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
Common/DTS.CommonCore/Base/Classes/BasePropertyChanged.cs
Common/DTS.CommonCore/Base/Classes/DisplayResourceAttribute.cs
Common/DTS.CommonCore/Base/Classes/DescriptionResourceAttribute.cs
Common/DTS.CommonCore/Base/Classes/DynamicTypeDescriptor.cs
2026-04-17T15:37:43.148987+00:00 zai-org/GLM-5-FP8 1 3c060c718b0c2281

Documentation: DTS.Common.Base Classes

1. Purpose

This module provides foundational infrastructure for the DTS common core library, offering three distinct capabilities: (1) a base implementation of the INotifyPropertyChanged pattern via BasePropertyChanged for MVVM-style data binding; (2) localization-aware attributes (DisplayResourceAttribute and DescriptionResourceAttribute) that resolve display names and descriptions from a centralized string resource manager at runtime; and (3) a sophisticated DynamicTypeDescriptor class that enables runtime modification of type metadata for scenarios requiring dynamic property grids or flexible property systems, such as Entity Framework scenarios where design-time properties need runtime adjustment.


2. Public Interface

BasePropertyChanged (Abstract Class)

Implements: IBasePropertyChanged

Member Signature Description
PropertyChanged event PropertyChangedEventHandler PropertyChanged Event raised when a property value changes. Marked virtual.
SetProperty<T> bool SetProperty<T>(ref T storage, T value, String propertyName = null) Sets the property value if different from current; returns true if changed, false otherwise. Raises PropertyChanged on change.
OnPropertyChanged void OnPropertyChanged(string propertyName = null) Raises the PropertyChanged event. Marked virtual.

DisplayResourceAttribute (Class)

Inherits: DisplayNameAttribute

Member Signature Description
Constructor DisplayResourceAttribute(string resourceId) Initializes with a resource identifier to look up.
DisplayName override string DisplayName Looks up the display name via Strings.Strings.ResourceManager.GetString(_resourceId). Returns "##ResourceNotFound##" + _resourceId if lookup fails.

DescriptionResourceAttribute (Class)

Inherits: DescriptionAttribute

Member Signature Description
Constructor DescriptionResourceAttribute(string resourceId) Initializes with a resource identifier to look up.
Description override string Description Looks up the description via Strings.Strings.ResourceManager.GetString(_resourceId). Returns "##DescriptionNotFound##" + _resourceId if lookup fails.

DynamicTypeDescriptor (Sealed Class)

Implements: ICustomTypeDescriptor, INotifyPropertyChanged

Member Signature Description
PropertyChanged event PropertyChangedEventHandler PropertyChanged Event raised when a property value changes.
Constructor DynamicTypeDescriptor(Type type) Initializes from a Type. Throws ArgumentNullException if type is null. Filters to only browsable properties.
GetPropertyValue<T> T GetPropertyValue<T>(string name, T defaultValue) Gets a property value by name, returning defaultValue if not found or on conversion failure. Throws ArgumentNullException if name is null.
SetPropertyValue void SetPropertyValue(string name, object value) Sets a property value by name. Throws ArgumentNullException if name is null.
AddProperty (overload 1) PropertyDescriptor AddProperty(Type type, string name, object value, string displayName, string description, string category, bool hasDefaultValue, object defaultValue, bool readOnly) Adds a dynamically defined property.
AddProperty (overload 2) PropertyDescriptor AddProperty(Type type, string name, object value, string displayName, string description, string category, bool hasDefaultValue, object defaultValue, bool readOnly, Type uiTypeEditor) Adds a dynamically defined property with a UI type editor. Throws ArgumentNullException if type or name is null.
AddProperty (overload 3) void AddProperty(PropertyDescriptor property) Adds an existing PropertyDescriptor. Throws ArgumentNullException if property is null.
RemoveProperty void RemoveProperty(string name) Removes all properties matching the given name. Throws ArgumentNullException if name is null.
FromComponent DynamicTypeDescriptor FromComponent(object component) Creates a new DynamicTypeDescriptor bound to a specific component instance. Throws ArgumentNullException if component is null; throws ArgumentException if component type is not assignable to _type.
OriginalProperties PropertyDescriptorCollection OriginalProperties { get; } The original properties from TypeDescriptor.GetProperties(type).
Properties PropertyDescriptorCollection Properties { get; } The current (potentially modified) property collection.
Component object Component { get; } The bound component instance.
ClassName string ClassName { get; set; } Optional override for class name.
ComponentName string ComponentName { get; set; } Optional override for component name.

DynamicTypeDescriptor.DynamicProperty (Nested Sealed Class)

Inherits: PropertyDescriptor, Implements: INotifyPropertyChanged

Member Signature Description
PropertyChanged event PropertyChangedEventHandler PropertyChanged Event raised when the property value changes.
Value object Value { get; set; } The current value (used when no existing property descriptor).
AttributesList IList<Attribute> AttributesList { get; } Mutable list of attributes.
Attributes override AttributeCollection Attributes { get; } Returns attributes as a collection.
SetBrowsable void SetBrowsable(bool browsable) Overrides the IsBrowsable behavior.
SetIsReadOnly void SetIsReadOnly(bool readOnly) Overrides the IsReadOnly behavior.
SetDisplayName void SetDisplayName(string displayName) Overrides the DisplayName.
SetDescription void SetDescription(string description) Overrides the Description.
SetCategory void SetCategory(string category) Overrides the Category.
SetEditor void SetEditor(Type editorBaseType, object obj) Sets or removes an editor for a given editor base type.
RemoveAttributesOfType<T> void RemoveAttributesOfType<T>() where T : Attribute Removes all attributes of the specified type from the property.
Standard PropertyDescriptor overrides CanResetValue, GetValue, SetValue, ResetValue, ShouldSerializeValue, GetEditor, etc. Standard property descriptor behavior, delegating to existing property when available.

3. Invariants

BasePropertyChanged

  • SetProperty<T> will not raise PropertyChanged if storage equals value (returns false early).
  • SetProperty<T> will always raise `