-Added serialization constructors to all Exceptions

-Added support for serialization event attributes on base classes
-Changed WriteEndObject, WriteEndArray, WriteEndConstructor on JsonWriter to be virtual
This commit is contained in:
JamesNK
2011-07-04 09:16:23 +00:00
parent b607b40753
commit c1cafd078d
9 changed files with 141 additions and 21 deletions
@@ -232,6 +232,32 @@ namespace Newtonsoft.Json.Tests.Serialization
// This value was set after deserialization.
}
public class SerializationEventBaseTestObject
{
public string TestMember { get; set; }
[OnSerializing]
internal void OnSerializingMethod(StreamingContext context)
{
TestMember = "Set!";
}
}
public class SerializationEventContextSubClassTestObject : SerializationEventBaseTestObject
{
}
[Test]
public void SerializationEventContextTestObjectSubClassTest()
{
SerializationEventContextSubClassTestObject obj = new SerializationEventContextSubClassTestObject();
string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
Assert.AreEqual(@"{
""TestMember"": ""Set!""
}", json);
}
#if !SILVERLIGHT
public class SerializationEventContextTestObject
{