public override bool Equals(object obj) { MyCustomType test = obj as MyCustomType; if (test != null) { if (!FirstName.Equals(test.FirstName)) { return(false); } if (!LastName.Equals(test.LastName)) { return(false); } if (!WhateverDate.Equals(test.WhateverDate)) { return(false); } if (!YouKnowIt.Equals(test.YouKnowIt)) { return(false); } if (!Items.SequenceEqual(test.Items)) { return(false); } return(true); } return(false); }
public void CustomDeserializer() { var store = GetDictionary(); store.Deserializers.Add(typeof(MyCustomType), (json) => JsonConvert.DeserializeObject <MyCustomType>(json)); var mycustom = new MyCustomType() { FirstName = "Bongo", LastName = "Juniper", WhateverDate = DateTime.Today.Add(new TimeSpan(27, 2, 0, 0)), YouKnowIt = true, Items = new MyNestedType[] { new MyNestedType() { OrderId = 232, Description = "This is great", Quantity = 2.4m, Price = 110m }, new MyNestedType() { OrderId = 118, Description = "This be the second item", Quantity = 45.2m, Price = 448m } } }; store["Custom"] = mycustom; Assert.IsTrue(store["Custom"].Equals(mycustom)); }