-Documentation

-Added Error event to JsonSerializer
This commit is contained in:
JamesNK
2009-10-11 04:23:35 +00:00
parent 0a45159376
commit b313445e01
25 changed files with 516 additions and 88 deletions
+16
View File
@@ -30,6 +30,7 @@ using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities;
using System.Runtime.Serialization;
using ErrorEventArgs=Newtonsoft.Json.Serialization.ErrorEventArgs;
namespace Newtonsoft.Json
{
@@ -60,6 +61,11 @@ namespace Newtonsoft.Json
#endif
};
/// <summary>
/// Occurs when the <see cref="JsonSerializer"/> errors during serialization and deserialization.
/// </summary>
public virtual event EventHandler<ErrorEventArgs> Error;
/// <summary>
/// Gets or sets the <see cref="IReferenceResolver"/> used by the serializer when resolving references.
/// </summary>
@@ -292,6 +298,9 @@ namespace Newtonsoft.Json
jsonSerializer.DefaultValueHandling = settings.DefaultValueHandling;
jsonSerializer.ConstructorHandling = settings.ConstructorHandling;
if (settings.Error != null)
jsonSerializer.Error += settings.Error;
if (settings.ContractResolver != null)
jsonSerializer.ContractResolver = settings.ContractResolver;
if (settings.ReferenceResolver != null)
@@ -445,5 +454,12 @@ namespace Newtonsoft.Json
matchingConverter = null;
return false;
}
internal void OnError(ErrorEventArgs e)
{
EventHandler<ErrorEventArgs> error = Error;
if (error != null)
error(this, e);
}
}
}