diff --git a/Src/Newtonsoft.Json/Serialization/JsonContract.cs b/Src/Newtonsoft.Json/Serialization/JsonContract.cs
index e376bc99..2a5c3f2e 100644
--- a/Src/Newtonsoft.Json/Serialization/JsonContract.cs
+++ b/Src/Newtonsoft.Json/Serialization/JsonContract.cs
@@ -24,6 +24,7 @@
#endregion
using System;
+using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using Newtonsoft.Json.Utilities;
@@ -89,29 +90,85 @@ namespace Newtonsoft.Json.Serialization
// checked for after passed in converters and attribute specified converters
internal JsonConverter InternalConverter { get; set; }
+ ///
+ /// Gets or sets all methods called immediately after deserialization of the object.
+ ///
+ /// The methods called immediately after deserialization of the object.
+ public List OnDeserializedMethods { get; set; }
+
+ ///
+ /// Gets or sets all methods called during deserialization of the object.
+ ///
+ /// The methods called during deserialization of the object.
+ public List OnDeserializingMethods { get; set; }
+
+ ///
+ /// Gets or sets all methods called after serialization of the object graph.
+ ///
+ /// The methods called after serialization of the object graph.
+ public List OnSerializedMethods { get; set; }
+
+ ///
+ /// Gets or sets all methods called before serialization of the object.
+ ///
+ /// The methods called before serialization of the object.
+ public List OnSerializingMethods { get; set; }
+
///
/// Gets or sets the method called immediately after deserialization of the object.
///
/// The method called immediately after deserialization of the object.
- public MethodInfo OnDeserialized { get; set; }
+ public MethodInfo OnDeserialized
+ {
+ get { return (OnDeserializedMethods != null && OnDeserializedMethods.Count > 0 ? OnDeserializedMethods[0] : null); }
+ set
+ {
+ OnDeserializedMethods = new List();
+ OnDeserializedMethods.Add(value);
+ }
+ }
///
/// Gets or sets the method called during deserialization of the object.
///
/// The method called during deserialization of the object.
- public MethodInfo OnDeserializing { get; set; }
+ public MethodInfo OnDeserializing
+ {
+ get { return (OnDeserializingMethods != null && OnDeserializingMethods.Count > 0 ? OnDeserializingMethods[0] : null); }
+ set
+ {
+ OnDeserializingMethods = new List();
+ OnDeserializingMethods.Add(value);
+ }
+ }
///
/// Gets or sets the method called after serialization of the object graph.
///
/// The method called after serialization of the object graph.
- public MethodInfo OnSerialized { get; set; }
+ public MethodInfo OnSerialized
+ {
+ get { return (OnSerializedMethods != null && OnSerializedMethods.Count > 0 ? OnSerializedMethods[0] : null); }
+ set
+ {
+ OnSerializedMethods = new List();
+ OnSerializedMethods.Add(value);
+ }
+ }
///
/// Gets or sets the method called before serialization of the object.
///
/// The method called before serialization of the object.
- public MethodInfo OnSerializing { get; set; }
+ public MethodInfo OnSerializing
+ {
+ get { return (OnSerializingMethods != null && OnSerializingMethods.Count > 0 ? OnSerializingMethods[0] : null); }
+ set
+ {
+ OnSerializingMethods = new List();
+ OnSerializingMethods.Add(value);
+ }
+ }
///
/// Gets or sets the default creator method used to create the object.
@@ -125,11 +182,25 @@ namespace Newtonsoft.Json.Serialization
/// true if the default object creator is non-public; otherwise, false.
public bool DefaultCreatorNonPublic { get; set; }
+ ///
+ /// Gets or sets all method called when an error is thrown during the serialization of the object.
+ ///
+ /// The methods called when an error is thrown during the serialization of the object.
+ public List OnErrorMethods { get; set; }
+
///
/// Gets or sets the method called when an error is thrown during the serialization of the object.
///
/// The method called when an error is thrown during the serialization of the object.
- public MethodInfo OnError { get; set; }
+ public MethodInfo OnError
+ {
+ get { return (OnErrorMethods != null && OnErrorMethods.Count > 0 ? OnErrorMethods[0] : null); }
+ set
+ {
+ OnErrorMethods = new List();
+ OnErrorMethods.Add(value);
+ }
+ }
internal void InvokeOnSerializing(object o, StreamingContext context)
{
@@ -206,4 +277,4 @@ namespace Newtonsoft.Json.Serialization
}
}
}
-}
\ No newline at end of file
+}