-Refactor
This commit is contained in:
@@ -207,21 +207,23 @@ namespace Newtonsoft.Json.Serialization
|
||||
{
|
||||
ValidationUtils.ArgumentNotNull(reader, "reader");
|
||||
|
||||
if (contract != null && contract.UnderlyingType == typeof(JRaw))
|
||||
if (contract != null)
|
||||
{
|
||||
return JRaw.Create(reader);
|
||||
if (contract.UnderlyingType == typeof(JRaw))
|
||||
return JRaw.Create(reader);
|
||||
if (reader.TokenType == JsonToken.Null
|
||||
&& !(contract.UnderlyingType == typeof(JValue) || contract.UnderlyingType == typeof(JToken)))
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
JToken token;
|
||||
using (JTokenWriter writer = new JTokenWriter())
|
||||
{
|
||||
writer.WriteToken(reader);
|
||||
token = writer.Token;
|
||||
}
|
||||
|
||||
return token;
|
||||
JToken token;
|
||||
using (JTokenWriter writer = new JTokenWriter())
|
||||
{
|
||||
writer.WriteToken(reader);
|
||||
token = writer.Token;
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
private JToken CreateJObject(JsonReader reader)
|
||||
@@ -268,15 +270,7 @@ namespace Newtonsoft.Json.Serialization
|
||||
private object CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue)
|
||||
{
|
||||
if (contract != null && contract.ContractType == JsonContractType.Linq)
|
||||
{
|
||||
JToken token = CreateJToken(reader, contract);
|
||||
|
||||
// test to make sure token is valid when null, e.g. can't set JValue.Null to JObject proeprty
|
||||
if (token.Type == JTokenType.Null && !contract.UnderlyingType.IsAssignableFrom(typeof(JValue)))
|
||||
return null;
|
||||
|
||||
return token;
|
||||
}
|
||||
return CreateJToken(reader, contract);
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user