Skip to content

Commit 1f53d9a

Browse files
committed
Making serializer optional for ApplicationDataStorageHelper and defaulting to SystemSerializer
1 parent fd8a1fd commit 1f53d9a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Microsoft.Toolkit.Uwp/Helpers/ObjectStorage/ApplicationDataStorageHelper.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public class ApplicationDataStorageHelper : IFileStorageHelper, ISettingsStorage
2020
/// <summary>
2121
/// Get a new instance using ApplicationData.Current and the provided serializer.
2222
/// </summary>
23-
/// <param name="objectSerializer">Serializer for converting stored values.</param>
23+
/// <param name="objectSerializer">Serializer for converting stored values. Defaults to <see cref="Toolkit.Helpers.SystemSerializer"/>.</param>
2424
/// <returns>A new instance of ApplicationDataStorageHelper.</returns>
25-
public static ApplicationDataStorageHelper GetCurrent(Toolkit.Helpers.IObjectSerializer objectSerializer)
25+
public static ApplicationDataStorageHelper GetCurrent(Toolkit.Helpers.IObjectSerializer objectSerializer = null)
2626
{
2727
var appData = ApplicationData.Current;
2828
return new ApplicationDataStorageHelper(appData, objectSerializer);
@@ -32,9 +32,9 @@ public static ApplicationDataStorageHelper GetCurrent(Toolkit.Helpers.IObjectSer
3232
/// Get a new instance using the ApplicationData for the provided user and serializer.
3333
/// </summary>
3434
/// <param name="user">App data user owner.</param>
35-
/// <param name="objectSerializer">Serializer for converting stored values.</param>
35+
/// <param name="objectSerializer">Serializer for converting stored values. Defaults to <see cref="Toolkit.Helpers.SystemSerializer"/>.</param>
3636
/// <returns>A new instance of ApplicationDataStorageHelper.</returns>
37-
public static async Task<ApplicationDataStorageHelper> GetForUserAsync(User user, Toolkit.Helpers.IObjectSerializer objectSerializer)
37+
public static async Task<ApplicationDataStorageHelper> GetForUserAsync(User user, Toolkit.Helpers.IObjectSerializer objectSerializer = null)
3838
{
3939
var appData = await ApplicationData.GetForUserAsync(user);
4040
return new ApplicationDataStorageHelper(appData, objectSerializer);
@@ -55,11 +55,11 @@ public static async Task<ApplicationDataStorageHelper> GetForUserAsync(User user
5555
/// Initializes a new instance of the <see cref="ApplicationDataStorageHelper"/> class.
5656
/// </summary>
5757
/// <param name="appData">The data store to interact with.</param>
58-
/// <param name="objectSerializer">Serializer for converting stored values.</param>
59-
public ApplicationDataStorageHelper(ApplicationData appData, Toolkit.Helpers.IObjectSerializer objectSerializer)
58+
/// <param name="objectSerializer">Serializer for converting stored values. Defaults to <see cref="Toolkit.Helpers.SystemSerializer"/>.</param>
59+
public ApplicationDataStorageHelper(ApplicationData appData, Toolkit.Helpers.IObjectSerializer objectSerializer = null)
6060
{
6161
AppData = appData ?? throw new ArgumentNullException(nameof(appData));
62-
_serializer = objectSerializer ?? throw new ArgumentNullException(nameof(objectSerializer));
62+
_serializer = objectSerializer ?? new Toolkit.Helpers.SystemSerializer();
6363
}
6464

6565
/// <inheritdoc />

0 commit comments

Comments
 (0)