This repository has been archived by the owner on Jan 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIniSection.cs
135 lines (108 loc) · 2.83 KB
/
IniSection.cs
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using System;
using System.Collections.Generic;
namespace RICADO.Ini
{
public class IniSection
{
#region Private Locals
private Dictionary<string, IniItem> m_itemsList = new Dictionary<string, IniItem>();
private string m_name = "";
private string m_comment = null;
#endregion
#region Public Properties
public string Name
{
get
{
return m_name;
}
}
public string Comment
{
get
{
return m_comment;
}
}
public int ItemCount
{
get
{
return m_itemsList.Count;
}
}
public Dictionary<string, IniItem> Items
{
get
{
return m_itemsList;
}
}
#endregion
#region Constructors
public IniSection(string name, string comment)
{
m_name = name;
m_comment = comment;
}
public IniSection(string name)
: this(name, null)
{
}
#endregion
#region Public Methods
public string GetValue(string key)
{
if (m_itemsList.ContainsKey(key))
{
return m_itemsList[key].Value;
}
else
{
return null;
}
}
public string[] GetKeys()
{
List<string> keys = new List<string>();
foreach (string key in m_itemsList.Keys)
{
keys.Add(key);
}
return keys.ToArray();
}
public bool ContainsKey(string key)
{
return m_itemsList.ContainsKey(key);
}
public void SetValue(string key, string value, string comment)
{
if (m_itemsList.ContainsKey(key))
{
m_itemsList[key].Value = value;
m_itemsList[key].Comment = comment;
}
else
{
IniItem item = new IniItem(key, value, enItemType.Key, comment);
m_itemsList.Add(key, item);
}
}
public void SetValue(string key, string value)
{
SetValue(key, value, null);
}
public void RemoveValue(string key)
{
if (m_itemsList.ContainsKey(key))
{
m_itemsList.Remove(key);
}
}
public Dictionary<string, IniItem>.Enumerator GetEnumerator()
{
return m_itemsList.GetEnumerator();
}
#endregion
}
}