Skip to content

Instantly share code, notes, and snippets.

luisgoncalves / DumpToConsoleDelegatingHandler.cs
Created September 5, 2018 16:28
class DumpToConsoleDelegatingHandler : DelegatingHandler
public DumpToConsoleDelegatingHandler()
InnerHandler = new HttpClientHandler();
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
luisgoncalves / SubTypesConverter.cs
Created October 3, 2018 22:27
A Json.NET converter that handles an hierarchy of types based on a custom discriminator property
class SubTypesConverter<T> : JsonConverter<T> where T: new()
private static bool isWriting;
private readonly string discriminatorName;
private readonly Dictionary<string, Func<T>> factories;
private readonly Dictionary<Type, string> discriminators;