C3031
2025-12-30 4196f211fedd0fdc2b83ea56bafe97ad14540b94
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace LB_SmartVisionCommon
{
    /// <summary>
    /// 动态属性描述符
    /// </summary>
    public class DynamicPropertyDescriptor : PropertyDescriptor
    {
        private readonly PropertyDescriptor _original;
        private readonly bool _isReadOnly;
        /// <summary>
        /// 动态属性描述符
        /// </summary>
        /// <param name="original">属性描述</param>
        /// <param name="isReadOnly">是否只读</param>
        public DynamicPropertyDescriptor(PropertyDescriptor original, bool isReadOnly)
            : base(original)
        {
            _original = original;
            _isReadOnly = isReadOnly;
        }
        /// <summary>
        /// 是否只读
        /// </summary>
        public override bool IsReadOnly => _isReadOnly;
        /// <summary>
        /// 当前组件类型
        /// </summary>
        public override Type ComponentType => _original.ComponentType;
        /// <summary>
        /// 属性类型
        /// </summary>
        public override Type PropertyType => _original.PropertyType;
        /// <summary>
        /// 返回重置对象时是否更改其值。
        /// </summary>
        /// <param name="component">要测试重置功能的组件。</param>
        /// <returns>如果重置组件更改其值,则为 true;否则为 false。</returns>
        public override bool CanResetValue(object component) => _original.CanResetValue(component);
        /// <summary>
        /// 返回给定对象支持的字段的值。
        /// </summary>
        /// <param name="component">将返回其字段值的对象。</param>
        /// <returns>一个对象,包含此实例反映的字段的值。</returns>
        public override object GetValue(object component) => _original.GetValue(component);
        /// <summary>
        /// 将组件的此属性的值重置为默认值。
        /// </summary>
        /// <param name="component">具有要重置为默认值的属性值的组件。</param>
        public override void ResetValue(object component) => _original.ResetValue(component);
        /// <summary>
        /// 设置指定对象的属性值。
        /// </summary>
        /// <param name="component">将设置其属性值的对象。</param>
        /// <param name="value">新的属性值。</param>
        public override void SetValue(object component, object value) => _original.SetValue(component, value);
        /// <summary>
        /// 确定一个值,该值指示是否需要永久保存此属性的值。
        /// </summary>
        /// <param name="component">具有要检查其持久性的属性的组件。</param>
        /// <returns>如果属性应该被永久保存,则为 true;否则为 false。</returns>
        public override bool ShouldSerializeValue(object component) => _original.ShouldSerializeValue(component);
    }
}