Skip to content

Instantly share code, notes, and snippets.

View Breno709's full-sized avatar

Breno Peçanha Breno709

  • Somniis
  • Guarapari, Brasil
View GitHub Profile
@SteveDunn
SteveDunn / convert.cs
Last active March 28, 2020 04:58
A JSON.net JsonConverter that serialises and deserialises a dictionaries where the key is a non-primitive/complex type
/// <summary>
/// Represents a JSON.net <see cref="JsonConverter"/> that serialises and deserialises a <see cref="Dictionary{TKey,TValue}"/>, where
/// <typeparamref name="TKey"/> is a non-primitive type, i.e. a type that is not a string, int, etc.
/// JSON.net uses the string representation of dictionary keys, which can cause problems with complex (non-primitive types).
/// You could override ToString, or add attributes to your type to overcome this problem, but the solution that this type
/// solves is for when you don't have access to the type being [de]serialised.
/// This solution was based on this StackOverflow answer (added the deserialisation part): https://stackoverflow.com/a/27043792/28901
/// </summary>
/// <typeparam name="TKey">The type of the key. Normally a complex type, but can be anything. If it's a non complex type, then this converter isn't needd.</typeparam>
/// <typeparam name="TValue">The value</typeparam>
@Breno709
Breno709 / Alert
Created September 16, 2014 03:15
ALERTA PARA MEMBROS!!!
Lembrar de, sempre antes de fazer alguma mudança, checar o branch que está alterando, NADA DE FAZER ALTERAÇÕES DIRETAS NO BRANCH MASTER!!!
@Breno709
Breno709 / Breno
Created September 13, 2014 04:39
tendando ainda fazer alog