@@ -20,32 +20,33 @@ public override Config AddBoolean(string section, string? subsection, string var
20
20
if ( value )
21
21
{
22
22
// Shortcut notation.
23
- return new FileConfig ( FilePath ,
24
- document . Add ( section , subsection , variable , null )
25
- . Save ( ) ) ;
23
+ document . Add ( section , subsection , variable , null ) . Save ( ) ;
26
24
}
27
25
else
28
26
{
29
- return new FileConfig ( FilePath ,
30
- document . Add ( section , subsection , variable , "false" )
31
- . Save ( ) ) ;
27
+ document . Add ( section , subsection , variable , "false" ) . Save ( ) ;
32
28
}
29
+
30
+ return this ;
33
31
}
34
32
35
33
public override Config AddDateTime ( string section , string ? subsection , string variable , DateTime value )
36
- => new FileConfig ( FilePath , document
37
- . Add ( section , subsection , variable , value . ToString ( "O" ) )
38
- . Save ( ) ) ;
34
+ {
35
+ document . Add ( section , subsection , variable , value . ToString ( "O" ) ) . Save ( ) ;
36
+ return this ;
37
+ }
39
38
40
39
public override Config AddNumber ( string section , string ? subsection , string variable , long value )
41
- => new FileConfig ( FilePath , document
42
- . Add ( section , subsection , variable , value . ToString ( ) )
43
- . Save ( ) ) ;
40
+ {
41
+ document . Add ( section , subsection , variable , value . ToString ( ) ) . Save ( ) ;
42
+ return this ;
43
+ }
44
44
45
45
public override Config AddString ( string section , string ? subsection , string variable , string value )
46
- => new FileConfig ( FilePath , document
47
- . Add ( section , subsection , variable , value )
48
- . Save ( ) ) ;
46
+ {
47
+ document . Add ( section , subsection , variable , value ) . Save ( ) ;
48
+ return this ;
49
+ }
49
50
50
51
public override IEnumerable < ConfigEntry > GetAll ( string section , string ? subsection , string variable , string ? valueRegex )
51
52
=> document . GetAll ( section , subsection , variable , valueRegex ) ;
@@ -69,78 +70,82 @@ public override IEnumerable<ConfigEntry> GetRegex(string nameRegex, string? valu
69
70
}
70
71
71
72
public override Config RemoveSection ( string section , string ? subsection )
72
- => new FileConfig ( FilePath , document
73
- . RemoveSection ( section , subsection )
74
- . Save ( ) ) ;
73
+ {
74
+ document . RemoveSection ( section , subsection ) . Save ( ) ;
75
+ return this ;
76
+ }
75
77
76
78
public override Config RenameSection ( string oldSection , string ? oldSubsection , string newSection , string ? newSubsection )
77
- => new FileConfig ( FilePath , document
78
- . RenameSection ( oldSection , oldSubsection , newSection , newSubsection )
79
- . Save ( ) ) ;
79
+ {
80
+ document . RenameSection ( oldSection , oldSubsection , newSection , newSubsection ) . Save ( ) ;
81
+ return this ;
82
+ }
80
83
81
84
public override Config SetAllBoolean ( string section , string ? subsection , string variable , bool value , string ? valueRegex )
82
85
{
83
86
if ( value )
84
87
{
85
88
// Shortcut notation.
86
- return new FileConfig ( FilePath , document
87
- . SetAll ( section , subsection , variable , null , valueRegex )
88
- . Save ( ) ) ;
89
+ document . SetAll ( section , subsection , variable , null , valueRegex ) . Save ( ) ;
89
90
}
90
91
else
91
92
{
92
- return new FileConfig ( FilePath , document
93
- . SetAll ( section , subsection , variable , "false" , valueRegex )
94
- . Save ( ) ) ;
93
+ document . SetAll ( section , subsection , variable , "false" , valueRegex ) . Save ( ) ;
95
94
}
95
+
96
+ return this ;
96
97
}
97
98
98
99
public override Config SetAllDateTime ( string section , string ? subsection , string variable , DateTime value , string ? valueRegex )
99
- => new FileConfig ( FilePath , document
100
- . SetAll ( section , subsection , variable , value . ToString ( "O" ) , valueRegex )
101
- . Save ( ) ) ;
100
+ {
101
+ document . SetAll ( section , subsection , variable , value . ToString ( "O" ) , valueRegex ) . Save ( ) ;
102
+ return this ;
103
+ }
102
104
103
105
public override Config SetAllNumber ( string section , string ? subsection , string variable , long value , string ? valueRegex )
104
- => new FileConfig ( FilePath , document
105
- . SetAll ( section , subsection , variable , value . ToString ( ) , valueRegex )
106
- . Save ( ) ) ;
106
+ {
107
+ document . SetAll ( section , subsection , variable , value . ToString ( ) , valueRegex ) . Save ( ) ;
108
+ return this ;
109
+ }
107
110
108
111
public override Config SetAllString ( string section , string ? subsection , string variable , string value , string ? valueRegex )
109
- => new FileConfig ( FilePath , document
110
- . SetAll ( section , subsection , variable , value , valueRegex )
111
- . Save ( ) ) ;
112
+ {
113
+ document . SetAll ( section , subsection , variable , value , valueRegex ) . Save ( ) ;
114
+ return this ;
115
+ }
112
116
113
117
public override Config SetBoolean ( string section , string ? subsection , string variable , bool value , string ? valueRegex )
114
118
{
115
119
if ( value )
116
120
{
117
121
// Shortcut notation.
118
- return new FileConfig ( FilePath , document
119
- . Set ( section , subsection , variable , null , valueRegex )
120
- . Save ( ) ) ;
122
+ document . Set ( section , subsection , variable , null , valueRegex ) . Save ( ) ;
121
123
}
122
124
else
123
125
{
124
- return new FileConfig ( FilePath , document
125
- . Set ( section , subsection , variable , "false" , valueRegex )
126
- . Save ( ) ) ;
126
+ document . Set ( section , subsection , variable , "false" , valueRegex ) . Save ( ) ;
127
127
}
128
+
129
+ return this ;
128
130
}
129
131
130
132
public override Config SetDateTime ( string section , string ? subsection , string variable , DateTime value , string ? valueRegex )
131
- => new FileConfig ( FilePath , document
132
- . Set ( section , subsection , variable , value . ToString ( "O" ) , valueRegex )
133
- . Save ( ) ) ;
133
+ {
134
+ document . Set ( section , subsection , variable , value . ToString ( "O" ) , valueRegex ) . Save ( ) ;
135
+ return this ;
136
+ }
134
137
135
138
public override Config SetNumber ( string section , string ? subsection , string variable , long value , string ? valueRegex )
136
- => new FileConfig ( FilePath , document
137
- . Set ( section , subsection , variable , value . ToString ( ) , valueRegex )
138
- . Save ( ) ) ;
139
+ {
140
+ document . Set ( section , subsection , variable , value . ToString ( ) , valueRegex ) . Save ( ) ;
141
+ return this ;
142
+ }
139
143
140
144
public override Config SetString ( string section , string ? subsection , string variable , string value , string ? valueRegex )
141
- => new FileConfig ( FilePath , document
142
- . Set ( section , subsection , variable , value , valueRegex )
143
- . Save ( ) ) ;
145
+ {
146
+ document . Set ( section , subsection , variable , value , valueRegex ) . Save ( ) ;
147
+ return this ;
148
+ }
144
149
145
150
public override bool TryGetBoolean ( string section , string ? subsection , string variable , out bool value )
146
151
{
@@ -211,14 +216,16 @@ public override bool TryGetString(string section, string? subsection, string var
211
216
}
212
217
213
218
public override Config Unset ( string section , string ? subsection , string variable )
214
- => new FileConfig ( FilePath , document
215
- . Unset ( section , subsection , variable )
216
- . Save ( ) ) ;
219
+ {
220
+ document . Unset ( section , subsection , variable ) . Save ( ) ;
221
+ return this ;
222
+ }
217
223
218
224
public override Config UnsetAll ( string section , string ? subsection , string variable , string ? valueMatcher )
219
- => new FileConfig ( FilePath , document
220
- . UnsetAll ( section , subsection , variable , valueMatcher )
221
- . Save ( ) ) ;
225
+ {
226
+ document . UnsetAll ( section , subsection , variable , valueMatcher ) . Save ( ) ;
227
+ return this ;
228
+ }
222
229
223
230
protected override IEnumerable < ConfigEntry > GetEntries ( ) => document ;
224
231
0 commit comments