@@ -27,19 +27,19 @@ public partial class ApplicationDataStorageHelper : IFileStorageHelper, ISetting
27
27
/// <param name="objectSerializer">Serializer for converting stored values. Defaults to <see cref="Toolkit.Helpers.SystemSerializer"/>.</param>
28
28
public ApplicationDataStorageHelper ( ApplicationData appData , Toolkit . Helpers . IObjectSerializer ? objectSerializer = null )
29
29
{
30
- this . AppData = appData ?? throw new ArgumentNullException ( nameof ( appData ) ) ;
31
- this . Serializer = objectSerializer ?? new Toolkit . Helpers . SystemSerializer ( ) ;
30
+ AppData = appData ?? throw new ArgumentNullException ( nameof ( appData ) ) ;
31
+ Serializer = objectSerializer ?? new Toolkit . Helpers . SystemSerializer ( ) ;
32
32
}
33
33
34
34
/// <summary>
35
35
/// Gets the settings container.
36
36
/// </summary>
37
- public ApplicationDataContainer Settings => this . AppData . LocalSettings ;
37
+ public ApplicationDataContainer Settings => AppData . LocalSettings ;
38
38
39
39
/// <summary>
40
40
/// Gets the storage folder.
41
41
/// </summary>
42
- public StorageFolder Folder => this . AppData . LocalFolder ;
42
+ public StorageFolder Folder => AppData . LocalFolder ;
43
43
44
44
/// <summary>
45
45
/// Gets the storage host.
@@ -81,7 +81,7 @@ public static async Task<ApplicationDataStorageHelper> GetForUserAsync(User user
81
81
/// <returns>True if a value exists.</returns>
82
82
public bool KeyExists ( string key )
83
83
{
84
- return this . Settings . Values . ContainsKey ( key ) ;
84
+ return Settings . Values . ContainsKey ( key ) ;
85
85
}
86
86
87
87
/// <summary>
@@ -93,9 +93,9 @@ public bool KeyExists(string key)
93
93
/// <returns>The TValue object.</returns>
94
94
public T ? Read < T > ( string key , T ? @default = default )
95
95
{
96
- if ( this . Settings . Values . TryGetValue ( key , out var valueObj ) && valueObj is string valueString )
96
+ if ( Settings . Values . TryGetValue ( key , out var valueObj ) && valueObj is string valueString )
97
97
{
98
- return this . Serializer . Deserialize < T > ( valueString ) ;
98
+ return Serializer . Deserialize < T > ( valueString ) ;
99
99
}
100
100
101
101
return @default ;
@@ -104,9 +104,9 @@ public bool KeyExists(string key)
104
104
/// <inheritdoc />
105
105
public bool TryRead < T > ( string key , out T ? value )
106
106
{
107
- if ( this . Settings . Values . TryGetValue ( key , out var valueObj ) && valueObj is string valueString )
107
+ if ( Settings . Values . TryGetValue ( key , out var valueObj ) && valueObj is string valueString )
108
108
{
109
- value = this . Serializer . Deserialize < T > ( valueString ) ;
109
+ value = Serializer . Deserialize < T > ( valueString ) ;
110
110
return true ;
111
111
}
112
112
@@ -117,19 +117,19 @@ public bool TryRead<T>(string key, out T? value)
117
117
/// <inheritdoc />
118
118
public void Save < T > ( string key , T value )
119
119
{
120
- this . Settings . Values [ key ] = this . Serializer . Serialize ( value ) ;
120
+ Settings . Values [ key ] = Serializer . Serialize ( value ) ;
121
121
}
122
122
123
123
/// <inheritdoc />
124
124
public bool TryDelete ( string key )
125
125
{
126
- return this . Settings . Values . Remove ( key ) ;
126
+ return Settings . Values . Remove ( key ) ;
127
127
}
128
128
129
129
/// <inheritdoc />
130
130
public void Clear ( )
131
131
{
132
- this . Settings . Values . Clear ( ) ;
132
+ Settings . Values . Clear ( ) ;
133
133
}
134
134
135
135
/// <summary>
@@ -140,7 +140,7 @@ public void Clear()
140
140
/// <returns>True if a value exists.</returns>
141
141
public bool KeyExists ( string compositeKey , string key )
142
142
{
143
- if ( this . TryRead ( compositeKey , out ApplicationDataCompositeValue ? composite ) && composite != null )
143
+ if ( TryRead ( compositeKey , out ApplicationDataCompositeValue ? composite ) && composite != null )
144
144
{
145
145
return composite . ContainsKey ( key ) ;
146
146
}
@@ -158,12 +158,12 @@ public bool KeyExists(string compositeKey, string key)
158
158
/// <returns>The T object.</returns>
159
159
public bool TryRead < T > ( string compositeKey , string key , out T ? value )
160
160
{
161
- if ( this . TryRead ( compositeKey , out ApplicationDataCompositeValue ? composite ) && composite != null )
161
+ if ( TryRead ( compositeKey , out ApplicationDataCompositeValue ? composite ) && composite != null )
162
162
{
163
163
string compositeValue = ( string ) composite [ key ] ;
164
164
if ( compositeValue != null )
165
165
{
166
- value = this . Serializer . Deserialize < T > ( compositeValue ) ;
166
+ value = Serializer . Deserialize < T > ( compositeValue ) ;
167
167
return true ;
168
168
}
169
169
}
@@ -182,11 +182,11 @@ public bool TryRead<T>(string compositeKey, string key, out T? value)
182
182
/// <returns>The T object.</returns>
183
183
public T ? Read < T > ( string compositeKey , string key , T ? @default = default )
184
184
{
185
- if ( this . TryRead ( compositeKey , out ApplicationDataCompositeValue ? composite ) && composite != null )
185
+ if ( TryRead ( compositeKey , out ApplicationDataCompositeValue ? composite ) && composite != null )
186
186
{
187
187
if ( composite . TryGetValue ( key , out object valueObj ) && valueObj is string value )
188
188
{
189
- return this . Serializer . Deserialize < T > ( value ) ;
189
+ return Serializer . Deserialize < T > ( value ) ;
190
190
}
191
191
}
192
192
@@ -203,17 +203,17 @@ public bool TryRead<T>(string compositeKey, string key, out T? value)
203
203
/// <param name="values">Objects to save.</param>
204
204
public void Save < T > ( string compositeKey , IDictionary < string , T > values )
205
205
{
206
- if ( this . TryRead ( compositeKey , out ApplicationDataCompositeValue ? composite ) && composite != null )
206
+ if ( TryRead ( compositeKey , out ApplicationDataCompositeValue ? composite ) && composite != null )
207
207
{
208
208
foreach ( KeyValuePair < string , T > setting in values )
209
209
{
210
210
if ( composite . ContainsKey ( setting . Key ) )
211
211
{
212
- composite [ setting . Key ] = this . Serializer . Serialize ( setting . Value ) ;
212
+ composite [ setting . Key ] = Serializer . Serialize ( setting . Value ) ;
213
213
}
214
214
else
215
215
{
216
- composite . Add ( setting . Key , this . Serializer . Serialize ( setting . Value ) ) ;
216
+ composite . Add ( setting . Key , Serializer . Serialize ( setting . Value ) ) ;
217
217
}
218
218
}
219
219
}
@@ -222,10 +222,10 @@ public void Save<T>(string compositeKey, IDictionary<string, T> values)
222
222
composite = new ApplicationDataCompositeValue ( ) ;
223
223
foreach ( KeyValuePair < string , T > setting in values )
224
224
{
225
- composite . Add ( setting . Key , this . Serializer . Serialize ( setting . Value ) ) ;
225
+ composite . Add ( setting . Key , Serializer . Serialize ( setting . Value ) ) ;
226
226
}
227
227
228
- this . Settings . Values [ compositeKey ] = composite ;
228
+ Settings . Values [ compositeKey ] = composite ;
229
229
}
230
230
}
231
231
@@ -237,7 +237,7 @@ public void Save<T>(string compositeKey, IDictionary<string, T> values)
237
237
/// <returns>A boolean indicator of success.</returns>
238
238
public bool TryDelete ( string compositeKey , string key )
239
239
{
240
- if ( this . TryRead ( compositeKey , out ApplicationDataCompositeValue ? composite ) && composite != null )
240
+ if ( TryRead ( compositeKey , out ApplicationDataCompositeValue ? composite ) && composite != null )
241
241
{
242
242
return composite . Remove ( key ) ;
243
243
}
@@ -248,43 +248,43 @@ public bool TryDelete(string compositeKey, string key)
248
248
/// <inheritdoc />
249
249
public Task < T ? > ReadFileAsync < T > ( string filePath , T ? @default = default )
250
250
{
251
- return this . ReadFileAsync < T > ( this . Folder , filePath , @default ) ;
251
+ return ReadFileAsync < T > ( Folder , filePath , @default ) ;
252
252
}
253
253
254
254
/// <inheritdoc />
255
255
public Task < IEnumerable < ( DirectoryItemType ItemType , string Name ) > > ReadFolderAsync ( string folderPath )
256
256
{
257
- return this . ReadFolderAsync ( this . Folder , folderPath ) ;
257
+ return ReadFolderAsync ( Folder , folderPath ) ;
258
258
}
259
259
260
260
/// <inheritdoc />
261
261
public Task CreateFileAsync < T > ( string filePath , T value )
262
262
{
263
- return this . CreateFileAsync < T > ( this . Folder , filePath , value ) ;
263
+ return CreateFileAsync < T > ( Folder , filePath , value ) ;
264
264
}
265
265
266
266
/// <inheritdoc />
267
267
public Task CreateFolderAsync ( string folderPath )
268
268
{
269
- return this . CreateFolderAsync ( this . Folder , folderPath ) ;
269
+ return CreateFolderAsync ( Folder , folderPath ) ;
270
270
}
271
271
272
272
/// <inheritdoc />
273
273
public Task < bool > TryDeleteItemAsync ( string itemPath )
274
274
{
275
- return TryDeleteItemAsync ( this . Folder , itemPath ) ;
275
+ return TryDeleteItemAsync ( Folder , itemPath ) ;
276
276
}
277
277
278
278
/// <inheritdoc />
279
279
public Task < bool > TryRenameItemAsync ( string itemPath , string newName )
280
280
{
281
- return TryRenameItemAsync ( this . Folder , itemPath , newName ) ;
281
+ return TryRenameItemAsync ( Folder , itemPath , newName ) ;
282
282
}
283
283
284
284
private async Task < T ? > ReadFileAsync < T > ( StorageFolder folder , string filePath , T ? @default = default )
285
285
{
286
286
string value = await StorageFileHelper . ReadTextFromFileAsync ( folder , NormalizePath ( filePath ) ) ;
287
- return ( value != null ) ? this . Serializer . Deserialize < T > ( value ) : @default ;
287
+ return ( value != null ) ? Serializer . Deserialize < T > ( value ) : @default ;
288
288
}
289
289
290
290
private async Task < IEnumerable < ( DirectoryItemType , string ) > > ReadFolderAsync ( StorageFolder folder , string folderPath )
@@ -304,7 +304,7 @@ public Task<bool> TryRenameItemAsync(string itemPath, string newName)
304
304
305
305
private async Task < StorageFile > CreateFileAsync < T > ( StorageFolder folder , string filePath , T value )
306
306
{
307
- return await StorageFileHelper . WriteTextToFileAsync ( folder , this . Serializer . Serialize ( value ) ? . ToString ( ) , NormalizePath ( filePath ) , CreationCollisionOption . ReplaceExisting ) ;
307
+ return await StorageFileHelper . WriteTextToFileAsync ( folder , Serializer . Serialize ( value ) ? . ToString ( ) , NormalizePath ( filePath ) , CreationCollisionOption . ReplaceExisting ) ;
308
308
}
309
309
310
310
private async Task CreateFolderAsync ( StorageFolder folder , string folderPath )
0 commit comments