-
Notifications
You must be signed in to change notification settings - Fork 3
/
IniSection.cs
65 lines (44 loc) · 1.7 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
using System;
using System.Collections;
using System.Collections.Generic;
namespace Gsemac.Text.Ini {
public class IniSection :
IIniSection {
// Public members
public string this[string propertyName] {
get => properties[propertyName]?.Value ?? string.Empty;
set => properties.Add(propertyName, value);
}
public string Name { get; } = string.Empty;
public string Comment { get; set; } = string.Empty;
public IIniPropertyCollection Properties => properties;
public IIniSectionCollection Sections => sections;
public int Count => properties.Count;
public bool IsReadOnly => properties.IsReadOnly;
public IniSection() :
this(string.Empty) {
}
public IniSection(IEqualityComparer<string> keyComparer) :
this(string.Empty, keyComparer) {
}
public IniSection(string name) :
this(name, EqualityComparer<string>.Default) {
}
public IniSection(string name, IEqualityComparer<string> keyComparer) {
if (keyComparer is null)
throw new ArgumentNullException(nameof(keyComparer));
Name = name;
properties = new IniPropertyCollection(keyComparer);
sections = new IniSectionCollection(keyComparer);
}
public IEnumerator<IIniProperty> GetEnumerator() {
return properties.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
// Private members
private readonly IIniPropertyCollection properties;
private readonly IIniSectionCollection sections;
}
}