diff --git a/DragonFruit.Common.Data/ApiClient.cs b/DragonFruit.Common.Data/ApiClient.cs
index c58f83d..5260ed4 100644
--- a/DragonFruit.Common.Data/ApiClient.cs
+++ b/DragonFruit.Common.Data/ApiClient.cs
@@ -7,11 +7,11 @@
using System.IO;
using System.Linq;
using System.Net.Http;
-using System.Runtime.CompilerServices;
using System.Threading;
using DragonFruit.Common.Data.Exceptions;
using DragonFruit.Common.Data.Headers;
using DragonFruit.Common.Data.Serializers;
+using DragonFruit.Common.Data.Utils;
#pragma warning disable 618
@@ -25,19 +25,12 @@ public class ApiClient
#region Constructors
///
- /// Initialises a new using an using the
+ /// Initialises a new using an with an optional
///
- public ApiClient()
- : this(new ApiJsonSerializer(CultureInfo.InvariantCulture))
- {
- }
-
- ///
- /// Initialises a new using an using a custom
- ///
- public ApiClient(CultureInfo culture)
- : this(new ApiJsonSerializer(culture))
+ public ApiClient(CultureInfo culture = null)
+ : this(new ApiJsonSerializer())
{
+ Serializer.Configure(o => o.Serializer.Culture = culture ?? CultureUtils.DefaultCulture);
}
///
@@ -347,7 +340,7 @@ protected T InternalPerform(HttpRequestMessage request, Func _lock.ExitReadLock();
}
}
diff --git a/DragonFruit.Common.Data/Serializers/SerializerResolver.cs b/DragonFruit.Common.Data/Serializers/SerializerResolver.cs
index 6a3684a..fa73c18 100644
--- a/DragonFruit.Common.Data/Serializers/SerializerResolver.cs
+++ b/DragonFruit.Common.Data/Serializers/SerializerResolver.cs
@@ -14,7 +14,6 @@ public class SerializerResolver
private static readonly Dictionary SerializerMap = new Dictionary();
private static readonly Dictionary DeserializerMap = new Dictionary();
- private ISerializer _default;
private readonly ConcurrentDictionary _serializerCache = new ConcurrentDictionary();
///
@@ -67,21 +66,9 @@ public static void Unregister(DataDirection direction = DataDirection.All)
}
///
- /// The default to use
+ /// The default in use.
///
- public ISerializer Default
- {
- get => _default;
- set
- {
- if (value is ApiSerializer { IsGeneric: false })
- {
- throw new ArgumentException("The provided serializer is non-generic.");
- }
-
- _default = value;
- }
- }
+ public ISerializer Default { get; }
///
/// Resolves the for the type provided
diff --git a/DragonFruit.Common.Data/TargetTypedApiClient.cs b/DragonFruit.Common.Data/TargetTypedApiClient.cs
new file mode 100644
index 0000000..acefaa8
--- /dev/null
+++ b/DragonFruit.Common.Data/TargetTypedApiClient.cs
@@ -0,0 +1,24 @@
+// DragonFruit.Common Copyright 2021 DragonFruit Network
+// Licensed under the MIT License. Please refer to the LICENSE file at the root of this project for details
+
+using System;
+using DragonFruit.Common.Data.Serializers;
+
+namespace DragonFruit.Common.Data
+{
+ ///
+ /// A superclass designed to allow better serializer configuration
+ ///
+ /// The to use
+ public class ApiClient : ApiClient where T : ApiSerializer, new()
+ {
+ public ApiClient(Action configurationOptions = null)
+ : base(Activator.CreateInstance())
+ {
+ if (configurationOptions != null)
+ {
+ Serializer.Configure(configurationOptions);
+ }
+ }
+ }
+}