88
99namespace CommunityToolkit . Datasync . Client . Serialization ;
1010
11- internal static class DatasyncSerializer
11+ /// <summary>
12+ /// The serialization settings for Datasync settings.
13+ /// </summary>
14+ public static class DatasyncSerializer
1215{
1316 private readonly static Lazy < JsonSerializerOptions > _initializer = new ( GetJsonSerializerOptions ) ;
17+ private static JsonSerializerOptions ? _userSuppliedOptions ;
1418
1519 /// <summary>
1620 /// Accessor for the common <see cref="JsonSerializerOptions"/> to use for serializing and deserializing
1721 /// content in the service.
1822 /// </summary>
19- internal static JsonSerializerOptions JsonSerializerOptions { get => _initializer . Value ; }
23+ public static JsonSerializerOptions JsonSerializerOptions
24+ {
25+ get => _userSuppliedOptions ?? _initializer . Value ;
26+ set => _userSuppliedOptions = value ;
27+ }
2028
2129 /// <summary>
2230 /// Serializes an object using the serializer options.
2331 /// </summary>
2432 /// <typeparam name="T">The type of the object.</typeparam>
2533 /// <param name="obj">The object.</param>
2634 /// <returns>The serialized version of the object.</returns>
27- internal static string Serialize < T > ( T obj )
35+ public static string Serialize < T > ( T obj )
2836 => JsonSerializer . Serialize ( obj , JsonSerializerOptions ) ;
2937
3038 /// <summary>
@@ -33,15 +41,15 @@ internal static string Serialize<T>(T obj)
3341 /// <param name="obj">The object.</param>
3442 /// <param name="objType">The type of the object.</param>
3543 /// <returns>The serialized version of the object.</returns>
36- internal static string Serialize ( object obj , Type objType )
44+ public static string Serialize ( object obj , Type objType )
3745 => JsonSerializer . Serialize ( obj , objType , JsonSerializerOptions ) ;
3846
3947 /// <summary>
4048 /// Internal method to create a new <see cref="JsonSerializerOptions"/> object for serializing and deserializing
4149 /// content in the service. You should never have to call this.
4250 /// </summary>
4351 /// <returns>A configured <see cref="JsonSerializerOptions"/> object.</returns>
44- internal static JsonSerializerOptions GetJsonSerializerOptions ( ) => new ( JsonSerializerDefaults . Web )
52+ public static JsonSerializerOptions GetJsonSerializerOptions ( ) => new ( JsonSerializerDefaults . Web )
4553 {
4654 AllowTrailingCommas = true ,
4755 Converters =
0 commit comments