public void ConverterDictionary() { ConverterDictionary <object> l1 = new ConverterDictionary <object>(); l1.Add("First", new DateTime(2000, 12, 12, 20, 10, 0, DateTimeKind.Utc)); l1.Add("Second", new DateTime(1983, 10, 9, 23, 10, 0, DateTimeKind.Utc)); string json = JsonConvert.SerializeObject(l1, Formatting.Indented); StringAssert.AreEqual(@"{ ""First"": new Date( 976651800000 ), ""Second"": new Date( 434589000000 ) }", json); ConverterDictionary <object> l2 = JsonConvert.DeserializeObject <ConverterDictionary <object> >(json); Assert.IsNotNull(l2); Assert.AreEqual(new DateTime(2000, 12, 12, 20, 10, 0, DateTimeKind.Utc), l2["First"]); Assert.AreEqual(new DateTime(1983, 10, 9, 23, 10, 0, DateTimeKind.Utc), l2["Second"]); }
static void Main(string[] args) { var cv = new ConverterDictionary(); var type2_converter = cv.GetConverter <Type2, Type2_New>(); var converterF = type2_converter.Compile(); var type2 = new Type2 { Field1 = "Hello", Field2 = "World" }; var type2_New = converterF(type2); }