-Added JsonConstructorAttribute to explicitly define which constructor to use during deserialization

-Added IFormattable to JValue
-Changed JValue ToString to call ToString on the internal value
-Fixed code emit error when deserializing interfaces in certain situations
This commit is contained in:
JamesNK
2011-01-15 00:44:26 +00:00
parent 5d062cc8f8
commit 3535173716
18 changed files with 347 additions and 32 deletions
+5 -1
View File
@@ -32,6 +32,7 @@ using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Utilities;
using System.Globalization;
using System.Text.RegularExpressions;
using System.IO;
namespace Newtonsoft.Json
{
@@ -300,8 +301,11 @@ namespace Newtonsoft.Json
if (schema.Enum != null)
{
StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
value.WriteTo(new JsonTextWriter(sw));
if (!schema.Enum.ContainsValue(value, new JTokenEqualityComparer()))
RaiseError("Value {0} is not defined in enum.".FormatWith(CultureInfo.InvariantCulture, value),
RaiseError("Value {0} is not defined in enum.".FormatWith(CultureInfo.InvariantCulture, sw.ToString()),
schema);
}