-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy pathIniScheme.cs
More file actions
129 lines (119 loc) · 4.27 KB
/
IniScheme.cs
File metadata and controls
129 lines (119 loc) · 4.27 KB
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
using IniParser.Model;
namespace IniParser.Configuration
{
/// <summary>
/// This structure defines the format of the INI file by customization the characters used to define sections
/// key/values or comments.
/// Used IniDataParser to read INI files, and an IIniDataFormatter to write a new ini file string.
/// </summary>
public class IniScheme : IDeepCloneable<IniScheme>
{
/// <summary>
/// Ctor.
/// </summary>
/// <remarks>
/// By default the various delimiters for the data are setted:
/// <para>';' for one-line comments</para>
/// <para>'[' ']' for delimiting a section</para>
/// <para>'=' for linking key / value pairs</para>
/// <example>
/// An example of well formed data with the default values:
/// <para>
/// ;section comment<br/>
/// [section] ; section comment<br/>
/// <br/>
/// ; key comment<br/>
/// key = value ;key comment<br/>
/// <br/>
/// ;key2 comment<br/>
/// key2 = value<br/>
/// </para>
/// </example>
/// </remarks>
public IniScheme()
{
}
/// <summary>
/// Copy ctor.
/// </summary>
/// <param name="ori">
/// Original instance to be copied.
/// </param>
IniScheme(IniScheme ori)
{
PropertyAssigmentString = ori.PropertyAssigmentString;
SectionStartString = ori.SectionStartString;
SectionEndString = ori.SectionEndString;
CommentString = ori.CommentString;
}
/// <summary>
/// Sets the string that defines the start of a comment.
/// A comment spans from the mirst matching comment string
/// to the end of the line.
/// </summary>
/// <remarks>
/// Defaults to string ";".
/// String returned will also be trimmed
/// </remarks>
public string CommentString
{
get => string.IsNullOrWhiteSpace(_commentString) ? ";" : _commentString;
set => _commentString = value?.Trim();
}
/// <summary>
/// Sets the string that defines the start of a section name.
/// </summary>
/// <remarks>
/// Defaults to "["
/// String returned will also be trimmed
/// </remarks>
public string SectionStartString
{
get => string.IsNullOrWhiteSpace(_sectionStartString) ? "[" : _sectionStartString;
set => _sectionStartString = value?.Trim();
}
/// <summary>
/// Sets the char that defines the end of a section name.
/// </summary>
/// <remarks>
/// Defaults to character ']'
/// String returned will also be trimmed
/// </remarks>
public string SectionEndString
{
get => string.IsNullOrWhiteSpace(_sectionEndString) ? "]" : _sectionEndString;
set => _sectionEndString = value?.Trim();
}
/// <summary>
/// Sets the string used in the ini file to denote a key / value assigment
/// </summary>
/// <remarks>
/// Defaults to character '='
/// String returned will also be trimmed
/// </remarks>
///
public string PropertyAssigmentString
{
get => string.IsNullOrWhiteSpace(_propertyAssigmentString) ? "=" : _propertyAssigmentString;
set => _propertyAssigmentString = value;
}
#region IDeepCloneable<T> Members
/// <summary>
/// Creates a new object that is a copy of the current instance.
/// </summary>
/// <returns>
/// A new object that is a copy of this instance.
/// </returns>
public IniScheme DeepClone()
{
return new IniScheme(this);
}
#endregion
#region Fields
string _commentString = ";";
string _sectionStartString = "[";
string _sectionEndString = "]";
string _propertyAssigmentString = "=";
#endregion
}
}