ホテル管理システム
ogi
yesterday 1a1c8e71fcd14858f595029f089b2d4a00202b32
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace HotelPms.Share.Windows.Component
{
    /// <summary>
    /// コントロールのプロパティの拡張
    /// GC.Collect();の直後、ConditionalWeakTableより自動で消える
    /// </summary>
    public class ControlPropertyEx
    {
        public static ConditionalWeakTable<Control, ControlPropertyEx> Data { get; set; } = new ConditionalWeakTable<Control, ControlPropertyEx>();
 
        /// <summary>
        /// 追加プロパティ
        /// </summary>
        public Dictionary<string, object> Addition { get; set; } = new Dictionary<string, object>();
 
        public override string ToString()
        {
            StringBuilder text = new StringBuilder();
            foreach(KeyValuePair<string, object> item in Addition)
            {
                text.Append($"{item.Key}={item.Value};");
            }
            return text.ToString();
        }
    }
}