schangxiang@126.com
2024-12-08 df485888ecb9f69c0051fc192b87aec700cc4f89
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
/*
 * CLR Version:4.0.30319.42000
 * NameSpace:WIP_common.CommonUtility
 * FileName:ConfigCommon
 * CurrentYear:2018
 * CurrentTime:2018/8/16 16:07:12
 * Author:shaocx
 *
 * <更新记录>
 * ver 1.0.0.0   2018/8/16 16:07:12 新規作成 (by shaocx)
 */
 
 
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ServiceClient
{
    [ConfigurationCollection(typeof(TheKeyValue))]
    public class TheKeyValueCollection : ConfigurationElementCollection        // 自定义一个集合
    {
        new TheKeyValue this[string name]
        {
            get
            {
                return (TheKeyValue)base.BaseGet(name);
            }
        }
 
        // 下面二个方法中抽象类中必须要实现的。
        protected override ConfigurationElement CreateNewElement()
        {
            return new TheKeyValue();
        }
 
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((TheKeyValue)element).Name;
        }
    }
 
    public class TheKeyValue : ConfigurationElement
    {
        [ConfigurationProperty("name", IsRequired = true)]
        public string Name
        {
            get { return this["name"].ToString(); }
            set { this["name"] = value; }
        }
 
        [ConfigurationProperty("text", IsRequired = true)]
        public string Text
        {
            get { return this["text"].ToString(); }
            set { this["text"] = value; }
        }
        [ConfigurationProperty("path", IsRequired = true)]
        public string Path
        {
            get { return this["path"].ToString(); }
            set { this["path"] = value; }
        }
    }
}