1
<?xml version="1.0" encoding="utf-8" ?>
2
<configuration>
3
<configSections>
4
<section name="TestSection" type="Test.TestSection,TestService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
5
</configSections>
6
<TestSection name="test" password="******">
7
<channels>
8
<add id="one" name="channel_1" />
9
<add id="two" name="channel_2" />
10
<add id="three" name="channel_3" />
11
</channels>
12
</TestSection>
13
</configuration>
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/None.gif)
13
![](/Images/OutliningIndicators/None.gif)
1、元素要继承ConfigurationElement
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using System.Configuration;
5
using System.Xml;
6
namespace Test
7
{
8
/// <summary>
9
/// 通道
10
/// </summary>
11
public class Channel : ConfigurationElement
12
{
13![](/Images/OutliningIndicators/InBlock.gif)
14
public Channel()
15
{
16![](/Images/OutliningIndicators/InBlock.gif)
17
}
18
public Channel(string name) : this(Guid.NewGuid().ToString(),name)
19
{
20
}
21
public Channel(string id ,string name)
22
{
23
ID = id;
24
Name = name;
25
}
26![](/Images/OutliningIndicators/InBlock.gif)
27
/// <summary>
28
/// 通道编号
29
/// </summary>
30
[ConfigurationProperty("id",IsRequired=true)]
31
public string ID
32
{
33
get { return (string) this["id"]; }
34
set { this["id"] = value; }
35
}
36![](/Images/OutliningIndicators/InBlock.gif)
37
/// <summary>
38
/// 通道名称
39
/// </summary>
40
[ConfigurationProperty("name",IsRequired=true)]
41
public string Name
42
{
43
get { return (string) this["name"]; }
44
set { this["name"] = value; }
45
}
46![](/Images/OutliningIndicators/InBlock.gif)
47
protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
48
{
49
base.DeserializeElement(reader, serializeCollectionKey);
50
}
51
protected override bool SerializeElement(XmlWriter writer, bool serializeCollectionKey)
52
{
53
return base.SerializeElement(writer, serializeCollectionKey);
54
}
55![](/Images/OutliningIndicators/InBlock.gif)
56
protected override bool IsModified()
57
{
58
return base.IsModified();
59
}
60
}
61
}
62![](/Images/OutliningIndicators/None.gif)
2、集合要继承ConfigurationElementCollection![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
8
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
20
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
33
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
34
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
35
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
40
![](/Images/OutliningIndicators/InBlock.gif)
41
![](/Images/OutliningIndicators/InBlock.gif)
42
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
43
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
44
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
45
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
46
![](/Images/OutliningIndicators/InBlock.gif)
47
![](/Images/OutliningIndicators/InBlock.gif)
48
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
49
![](/Images/OutliningIndicators/InBlock.gif)
50
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
55
![](/Images/OutliningIndicators/InBlock.gif)
56
![](/Images/OutliningIndicators/InBlock.gif)
57
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
58
![](/Images/OutliningIndicators/InBlock.gif)
59
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
60
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
61
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
62
![](/Images/OutliningIndicators/None.gif)
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using System.Configuration;
5
namespace Test
6
{
7
public class ChannelCollection : ConfigurationElementCollection
8
{
9
public ChannelCollection()
10
{
11
Channel channel = (Channel)CreateNewElement();
12
Add(channel);
13
}
14![](/Images/OutliningIndicators/InBlock.gif)
15
public override ConfigurationElementCollectionType CollectionType
16
{
17
get
18
{
19
return ConfigurationElementCollectionType.AddRemoveClearMap;
20
}
21
}
22![](/Images/OutliningIndicators/InBlock.gif)
23
protected override ConfigurationElement CreateNewElement()
24
{
25
return new Channel();
26
}
27![](/Images/OutliningIndicators/InBlock.gif)
28![](/Images/OutliningIndicators/InBlock.gif)
29
protected override ConfigurationElement CreateNewElement(string elementName)
30
{
31
return new Channel(elementName);
32
}
33![](/Images/OutliningIndicators/InBlock.gif)
34![](/Images/OutliningIndicators/InBlock.gif)
35
protected override Object GetElementKey(ConfigurationElement element)
36
{
37
return ((Channel)element).Name;
38
}
39![](/Images/OutliningIndicators/InBlock.gif)
40![](/Images/OutliningIndicators/InBlock.gif)
41
public new string AddElementName
42
{
43
get
44
{ return base.AddElementName; }
45![](/Images/OutliningIndicators/InBlock.gif)
46
set
47
{ base.AddElementName = value; }
48![](/Images/OutliningIndicators/InBlock.gif)
49
}
50![](/Images/OutliningIndicators/InBlock.gif)
51
public new string ClearElementName
52
{
53
get
54
{ return base.ClearElementName; }
55![](/Images/OutliningIndicators/InBlock.gif)
56
set
57
{ base.AddElementName = value; }
58![](/Images/OutliningIndicators/InBlock.gif)
59
}
60![](/Images/OutliningIndicators/InBlock.gif)
61
public new string RemoveElementName
62
{
63
get
64
{ return base.RemoveElementName; }
65![](/Images/OutliningIndicators/InBlock.gif)
66![](/Images/OutliningIndicators/InBlock.gif)
67
}
68![](/Images/OutliningIndicators/InBlock.gif)
69
public new int Count
70
{
71![](/Images/OutliningIndicators/InBlock.gif)
72
get { return base.Count; }
73![](/Images/OutliningIndicators/InBlock.gif)
74
}
75![](/Images/OutliningIndicators/InBlock.gif)
76![](/Images/OutliningIndicators/InBlock.gif)
77
public Channel this[int index]
78
{
79
get
80
{
81
return (Channel)BaseGet(index);
82
}
83
set
84
{
85
if (BaseGet(index) != null)
86
{
87
BaseRemoveAt(index);
88
}
89
BaseAdd(index, value);
90
}
91
}
92![](/Images/OutliningIndicators/InBlock.gif)
93
new public Channel this[string Name]
94
{
95
get
96
{
97
return (Channel)BaseGet(Name);
98
}
99
}
100![](/Images/OutliningIndicators/InBlock.gif)
101
public int IndexOf(Channel channel)
102
{
103
return BaseIndexOf(channel);
104
}
105![](/Images/OutliningIndicators/InBlock.gif)
106
public void Add(Channel channel)
107
{
108
BaseAdd(channel);
109![](/Images/OutliningIndicators/InBlock.gif)
110
// Add custom code here.
111
}
112![](/Images/OutliningIndicators/InBlock.gif)
113
protected override void
114
BaseAdd(ConfigurationElement element)
115
{
116
BaseAdd(element, false);
117
// Add custom code here.
118
}
119![](/Images/OutliningIndicators/InBlock.gif)
120
public void Remove(Channel channel)
121
{
122
if (BaseIndexOf(channel) >= 0)
123
BaseRemove(channel.Name);
124
}
125![](/Images/OutliningIndicators/InBlock.gif)
126
public void RemoveAt(int index)
127
{
128
BaseRemoveAt(index);
129
}
130![](/Images/OutliningIndicators/InBlock.gif)
131
public void Remove(string name)
132
{
133
BaseRemove(name);
134
}
135![](/Images/OutliningIndicators/InBlock.gif)
136
public void Clear()
137
{
138
BaseClear();
139
// Add custom code here.
140
}
141
}
142
}
3、节点要继承ConfigurationSection![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
7
![](/Images/OutliningIndicators/InBlock.gif)
8
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
21
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
37
![](/Images/OutliningIndicators/InBlock.gif)
38
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/InBlock.gif)
41
![](/Images/OutliningIndicators/InBlock.gif)
42
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
45
![](/Images/OutliningIndicators/InBlock.gif)
46
![](/Images/OutliningIndicators/InBlock.gif)
47
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
48
![](/Images/OutliningIndicators/InBlock.gif)
49
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
50
![](/Images/OutliningIndicators/InBlock.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
55
![](/Images/OutliningIndicators/InBlock.gif)
56
![](/Images/OutliningIndicators/InBlock.gif)
57
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
58
![](/Images/OutliningIndicators/InBlock.gif)
59
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
60
![](/Images/OutliningIndicators/InBlock.gif)
61
![](/Images/OutliningIndicators/InBlock.gif)
62
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
63
![](/Images/OutliningIndicators/InBlock.gif)
64
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
65
![](/Images/OutliningIndicators/InBlock.gif)
66
![](/Images/OutliningIndicators/InBlock.gif)
67
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
68
![](/Images/OutliningIndicators/InBlock.gif)
69
![](/Images/OutliningIndicators/InBlock.gif)
70
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
71
![](/Images/OutliningIndicators/InBlock.gif)
72
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
73
![](/Images/OutliningIndicators/InBlock.gif)
74
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
75
![](/Images/OutliningIndicators/InBlock.gif)
76
![](/Images/OutliningIndicators/InBlock.gif)
77
![](/Images/OutliningIndicators/InBlock.gif)
78
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
79
![](/Images/OutliningIndicators/InBlock.gif)
80
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
81
![](/Images/OutliningIndicators/InBlock.gif)
82
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
83
![](/Images/OutliningIndicators/InBlock.gif)
84
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
85
![](/Images/OutliningIndicators/InBlock.gif)
86
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
87
![](/Images/OutliningIndicators/InBlock.gif)
88
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
89
![](/Images/OutliningIndicators/InBlock.gif)
90
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
91
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
92
![](/Images/OutliningIndicators/InBlock.gif)
93
![](/Images/OutliningIndicators/InBlock.gif)
94
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
95
![](/Images/OutliningIndicators/InBlock.gif)
96
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
97
![](/Images/OutliningIndicators/InBlock.gif)
98
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
99
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
100
![](/Images/OutliningIndicators/InBlock.gif)
101
![](/Images/OutliningIndicators/InBlock.gif)
102
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
103
![](/Images/OutliningIndicators/InBlock.gif)
104
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
105
![](/Images/OutliningIndicators/InBlock.gif)
106
![](/Images/OutliningIndicators/InBlock.gif)
107
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
108
![](/Images/OutliningIndicators/InBlock.gif)
109
![](/Images/OutliningIndicators/InBlock.gif)
110
![](/Images/OutliningIndicators/InBlock.gif)
111
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
112
![](/Images/OutliningIndicators/InBlock.gif)
113
![](/Images/OutliningIndicators/InBlock.gif)
114
![](/Images/OutliningIndicators/InBlock.gif)
115
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
116
![](/Images/OutliningIndicators/InBlock.gif)
117
![](/Images/OutliningIndicators/InBlock.gif)
118
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
119
![](/Images/OutliningIndicators/InBlock.gif)
120
![](/Images/OutliningIndicators/InBlock.gif)
121
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
122
![](/Images/OutliningIndicators/InBlock.gif)
123
![](/Images/OutliningIndicators/InBlock.gif)
124
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
125
![](/Images/OutliningIndicators/InBlock.gif)
126
![](/Images/OutliningIndicators/InBlock.gif)
127
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
128
![](/Images/OutliningIndicators/InBlock.gif)
129
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
130
![](/Images/OutliningIndicators/InBlock.gif)
131
![](/Images/OutliningIndicators/InBlock.gif)
132
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
133
![](/Images/OutliningIndicators/InBlock.gif)
134
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
135
![](/Images/OutliningIndicators/InBlock.gif)
136
![](/Images/OutliningIndicators/InBlock.gif)
137
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
138
![](/Images/OutliningIndicators/InBlock.gif)
139
![](/Images/OutliningIndicators/InBlock.gif)
140
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
141
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
142
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using System.Configuration;
5
using System.Xml;
6![](/Images/OutliningIndicators/None.gif)
7
namespace Test
8
{
9
/// <summary>
10
/// Test配置信息
11
/// </summary>
12
public class TestSection : ConfigurationSection
13
{
14
/// <summary>
15
/// Test名称
16
/// </summary>
17
[ConfigurationProperty("name",IsRequired=true)]
18
public string Name
19
{
20
get { return (string) this["name"]; }
21
set { this["name"] = value; }
22
}
23
24
/// <summary>
25
/// Test通道集合
26
/// </summary>
27
[ConfigurationProperty("channels",IsDefaultCollection = false)]
28
public ChannelCollection Channels
29
{
30
get
31
{
32
ChannelCollection channels = (ChannelCollection)base["channels"];
33
return channels;
34
35
}
36
37
}
38![](/Images/OutliningIndicators/InBlock.gif)
39
/// <summary>
40
/// 密码
41
/// </summary>
42
[ConfigurationProperty("password",IsRequired= true)]
43
public string Password
44
{
45
get { return (string) this["password"]; }
46
set { this["password"] = value; }
47
}
48![](/Images/OutliningIndicators/InBlock.gif)
49
protected override void DeserializeSection(XmlReader reader)
50
{
51
base.DeserializeSection(reader);
52
}
53![](/Images/OutliningIndicators/InBlock.gif)
54
protected override string SerializeSection(ConfigurationElement parentElement, string name, ConfigurationSaveMode saveMode)
55
{
56
string s = base.SerializeSection(parentElement, name, saveMode);
57
return s;
58
}
59
}
60
}
61![](/Images/OutliningIndicators/None.gif)
4、Demo![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
9
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
14
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
20
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
21
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
22
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
27
![](/Images/OutliningIndicators/InBlock.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
40
![](/Images/OutliningIndicators/InBlock.gif)
41
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
42
![](/Images/OutliningIndicators/InBlock.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
45
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
46
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
47
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
48
![](/Images/OutliningIndicators/InBlock.gif)
49
![](/Images/OutliningIndicators/InBlock.gif)
50
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/InBlock.gif)
55
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
56
![](/Images/OutliningIndicators/InBlock.gif)
57
![](/Images/OutliningIndicators/InBlock.gif)
58
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
59
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
60
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
61
![](/Images/OutliningIndicators/None.gif)
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Text;
7
using System.Windows.Forms;
8
using System.Configuration;
9![](/Images/OutliningIndicators/None.gif)
10
namespace Test
11
{
12
public partial class Demo : Form
13
{
14
public Demo()
15
{
16
InitializeComponent();
17
}
18![](/Images/OutliningIndicators/InBlock.gif)
19
private void button1_Click(object sender, EventArgs e)
20
{
21
SaveConfig();
22
}
23
public void SaveConfig()
24
{
25
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
26![](/Images/OutliningIndicators/InBlock.gif)
27
Channel[] channel = { new Channel("one","channel_Red"),
28
new Channel("two","channel_Blue"),
29
new Channel("three","channel_Green")
30
};
31![](/Images/OutliningIndicators/InBlock.gif)
32
config.Sections.Remove("ClientSection");
33![](/Images/OutliningIndicators/InBlock.gif)
34
ClientSection section = new ClientSection();
35
section.Name = "服务器1";
36
section.Password = "123456";
37
for (int i = 0; i < channel.Length; i++)
38
{
39
section.Channels.Add(channel[i]);
40
}
41
config.Sections.Add("ClientSection", section);
42
config.Save();
43
}
44
}
45
}
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/InBlock.gif)
38
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
41
![](/Images/OutliningIndicators/InBlock.gif)
42
![](/Images/OutliningIndicators/InBlock.gif)
43
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
44
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
45
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)