-Formatting

-Build
This commit is contained in:
James Newton-King
2015-12-04 23:54:38 +13:00
parent c96779dc10
commit eb0cbd6a75
334 changed files with 3952 additions and 514 deletions
@@ -72,7 +72,9 @@ namespace Newtonsoft.Json.Converters
}
#endif
if (value is SqlBinary)
{
return ((SqlBinary)value).Value;
}
throw new JsonSerializationException("Unexpected value type when writing binary: {0}".FormatWith(CultureInfo.InvariantCulture, value.GetType()));
}
@@ -81,7 +83,9 @@ namespace Newtonsoft.Json.Converters
private void EnsureReflectionObject(Type t)
{
if (_reflectionObject == null)
{
_reflectionObject = ReflectionObject.Create(t, t.GetConstructor(new[] { typeof(byte[]) }), BinaryToArrayName);
}
}
#endif
@@ -102,7 +106,9 @@ namespace Newtonsoft.Json.Converters
if (reader.TokenType == JsonToken.Null)
{
if (!ReflectionUtils.IsNullable(objectType))
{
throw JsonSerializationException.Create(reader, "Cannot convert null value to {0}.".FormatWith(CultureInfo.InvariantCulture, objectType));
}
return null;
}
@@ -135,7 +141,9 @@ namespace Newtonsoft.Json.Converters
#endif
if (t == typeof(SqlBinary))
{
return new SqlBinary(data);
}
throw JsonSerializationException.Create(reader, "Unexpected object type when writing binary: {0}".FormatWith(CultureInfo.InvariantCulture, objectType));
}
@@ -175,14 +183,19 @@ namespace Newtonsoft.Json.Converters
{
#if !NET20
if (objectType.AssignableToTypeName(BinaryTypeName))
{
return true;
}
#endif
if (objectType == typeof(SqlBinary) || objectType == typeof(SqlBinary?))
{
return true;
}
return false;
}
}
}
#endif