using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Collections.Specialized;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public class NotificationDTO
public long idCompanyService { get; set; }
public List<Tuple<string, byte[], System.Net.Mime.ContentType>> Attachments { get; set; }
public static void Test()
static void TestStringDictionary()
StringDictionary myCol = new StringDictionary();
myCol.Add( "red", "rojo" );
myCol.Add( "green", "verde" );
myCol.Add( "blue", "azul" );
myCol.Add( "blue", "2azul" );
var json = JsonConvert.SerializeObject(myCol);
var json = @"{""Boundary"":null,""CharSet"":null,""MediaType"":""application/pdf"",""Name"":null,""Parameters"":[]}";
Console.WriteLine("Trying to deserialize a {0}: ", typeof(System.Net.Mime.ContentType));
var content = JsonConvert.DeserializeObject<System.Net.Mime.ContentType>(json);
var json2 = JsonConvert.SerializeObject(content, Formatting.Indented);
Console.WriteLine(json2);
public static void TestFull()
var json = @"{""idCompanyService"":1234,""DocumentType"":0,""Attachments"":[{""Item1"":""test.pdf"",""Item2"":""AAAA"",""Item3"":{""Boundary"":null,""CharSet"":null,""MediaType"":""application/pdf"",""Name"":null,""Parameters"":[]}}}";
Console.WriteLine("Trying to deserialize a {0}: ", typeof(NotificationDTO));
var dto = JsonConvert.DeserializeObject<NotificationDTO>(json);
var json2 = JsonConvert.SerializeObject(dto, Formatting.Indented);
Console.WriteLine(json2);
public static void Main()
Console.WriteLine("Environment version: " + Environment.Version);
Console.WriteLine("Json.NET version: " + typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");