Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Modrinth.Net/Http/Requester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class Requester : IRequester
public Requester(ModrinthClientConfig config, HttpClient? httpClient = null)
{
_config = config;
if (config.JsonSerializerContext != null)
_jsonSerializerOptions.TypeInfoResolverChain.Add(config.JsonSerializerContext);
_semaphore = new SemaphoreSlim(_config.MaxConcurrentRequests);

HttpClient = httpClient ?? new HttpClient();
Expand Down
10 changes: 9 additions & 1 deletion src/Modrinth.Net/ModrinthClientConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Modrinth;
using System.Text.Json.Serialization.Metadata;

namespace Modrinth;

/// <summary>
/// Object containing options for <see cref="ModrinthClient" />
Expand Down Expand Up @@ -41,6 +43,12 @@ public class ModrinthClientConfig
/// Default is 100.
/// </summary>
public int BatchSize { get; set; } = 100;

/// <summary>
/// The JSON serializer context to use for serialization and deserialization.
/// If null, the client will use the default serializer with reflection-based serialization, which is less performant.
/// </summary>
public IJsonTypeInfoResolver? JsonSerializerContext { get; set; }

/// <summary>
/// Validates the configuration options.
Expand Down
Loading