@@ -10,7 +10,7 @@ public class ModifiedConfigurationSettings : IConfigurationSettings
1010 {
1111 public readonly ConfigurationSettings OriginalSettings ;
1212
13- public readonly IReadOnlyDictionary < string , string > Changes ;
13+ public readonly IReadOnlyDictionary < string , string > NewValues ;
1414
1515 public int Version => OriginalSettings . Version ;
1616
@@ -22,13 +22,13 @@ public ModifiedConfigurationSettings(params (string Key, string Value)[] setting
2222
2323 public ModifiedConfigurationSettings ( ConfigurationSettings originalSettings , IReadOnlyDictionary < string , string > changes )
2424 {
25- OriginalSettings = originalSettings ?? new ConfigurationSettings ( ) ;
26- Changes = changes ?? throw new ArgumentNullException ( nameof ( changes ) ) ;
25+ OriginalSettings = originalSettings ?? ConfigurationSettings . Empty ( ) ;
26+ NewValues = changes ?? throw new ArgumentNullException ( nameof ( changes ) ) ;
2727 }
2828
29- public IConfigurationSettings Modify ( params ( string Key , string Value ) [ ] modifications )
29+ public ModifiedConfigurationSettings WithModifiedSettings ( params ( string Key , string Value ) [ ] modifications )
3030 {
31- var modified = Changes . ToDictionary ( x => x . Key , x => x . Value , StringComparer . OrdinalIgnoreCase ) ;
31+ var modified = NewValues . ToDictionary ( x => x . Key , x => x . Value , StringComparer . OrdinalIgnoreCase ) ;
3232 foreach ( var modification in modifications )
3333 {
3434 modified [ modification . Key ] = modification . Value ;
@@ -37,14 +37,14 @@ public IConfigurationSettings Modify(params (string Key, string Value)[] modific
3737 }
3838
3939
40- public IConfigurationSettings Set ( IReadOnlyDictionary < string , string > replacement )
40+ public ModifiedConfigurationSettings WithAllSettingsReplaced ( IReadOnlyDictionary < string , string > replacement )
4141 {
4242 return new ModifiedConfigurationSettings ( OriginalSettings , replacement ) ;
4343 }
4444
45- public IConfigurationSettings Delete ( params string [ ] deletions )
45+ public ModifiedConfigurationSettings WithDeletedKeys ( params string [ ] deletions )
4646 {
47- var modified = Changes . ToDictionary ( x => x . Key , x => x . Value , StringComparer . OrdinalIgnoreCase ) ;
47+ var modified = NewValues . ToDictionary ( x => x . Key , x => x . Value , StringComparer . OrdinalIgnoreCase ) ;
4848 foreach ( var deletion in deletions )
4949 {
5050 modified . Remove ( deletion ) ;
@@ -55,11 +55,11 @@ public IConfigurationSettings Delete(params string[] deletions)
5555 public ConfigChanged GetChanges ( )
5656 {
5757 var deleted = new HashSet < string > (
58- collection : OriginalSettings . Settings . Keys . Where ( x => ! Changes . ContainsKey ( x ) ) ,
58+ collection : OriginalSettings . Settings . Keys . Where ( x => ! NewValues . ContainsKey ( x ) ) ,
5959 comparer : StringComparer . InvariantCultureIgnoreCase ) ;
6060
6161 var modified = new HashSet < string > (
62- collection : Changes . Where ( IsModified ) . Select ( x => x . Key ) ,
62+ collection : NewValues . Where ( IsModified ) . Select ( x => x . Key ) ,
6363 comparer : StringComparer . InvariantCultureIgnoreCase ) ;
6464
6565 if ( ! deleted . Any ( ) && ! modified . Any ( ) )
@@ -68,7 +68,7 @@ public ConfigChanged GetChanges()
6868 return null ;
6969 }
7070 return new ConfigChanged (
71- allSettings : Changes . ToDictionary ( x => x . Key , x => x . Value ) ,
71+ allSettings : NewValues . ToDictionary ( x => x . Key , x => x . Value ) ,
7272 modifiedSettings : modified ,
7373 deletedSettings : deleted ) ;
7474 }
@@ -87,30 +87,30 @@ private bool IsModified(KeyValuePair<string, string> modifiedKvp)
8787
8888 public IEnumerator < KeyValuePair < string , string > > GetEnumerator ( )
8989 {
90- return Changes . GetEnumerator ( ) ;
90+ return NewValues . GetEnumerator ( ) ;
9191 }
9292
9393 IEnumerator IEnumerable . GetEnumerator ( )
9494 {
95- return ( ( IEnumerable ) Changes ) . GetEnumerator ( ) ;
95+ return ( ( IEnumerable ) NewValues ) . GetEnumerator ( ) ;
9696 }
9797
98- public int Count => Changes . Count ;
98+ public int Count => NewValues . Count ;
9999
100100 public bool ContainsKey ( string key )
101101 {
102- return Changes . ContainsKey ( key ) ;
102+ return NewValues . ContainsKey ( key ) ;
103103 }
104104
105105 public bool TryGetValue ( string key , out string value )
106106 {
107- return Changes . TryGetValue ( key , out value ) ;
107+ return NewValues . TryGetValue ( key , out value ) ;
108108 }
109109
110- public string this [ string key ] => Changes [ key ] ;
110+ public string this [ string key ] => NewValues [ key ] ;
111111
112- public IEnumerable < string > Keys => Changes . Keys ;
112+ public IEnumerable < string > Keys => NewValues . Keys ;
113113
114- public IEnumerable < string > Values => Changes . Values ;
114+ public IEnumerable < string > Values => NewValues . Values ;
115115 }
116116}
0 commit comments