-Clean up

This commit is contained in:
James Newton-King
2014-03-01 18:39:21 +13:00
parent b43afdcc0a
commit f568413717
6 changed files with 14 additions and 12 deletions
+3 -2
View File
@@ -28,6 +28,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
using System.IO; using System.IO;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@@ -356,7 +357,7 @@ namespace Newtonsoft.Json.Bson
{ {
case State.ObjectStart: case State.ObjectStart:
{ {
SetToken(JsonToken.PropertyName, "$ref"); SetToken(JsonToken.PropertyName, JsonTypeReflector.RefPropertyName);
_bsonReaderState = BsonReaderState.ReferenceRef; _bsonReaderState = BsonReaderState.ReferenceRef;
return true; return true;
} }
@@ -381,7 +382,7 @@ namespace Newtonsoft.Json.Bson
{ {
if (_bsonReaderState == BsonReaderState.ReferenceRef) if (_bsonReaderState == BsonReaderState.ReferenceRef)
{ {
SetToken(JsonToken.PropertyName, "$id"); SetToken(JsonToken.PropertyName, JsonTypeReflector.IdPropertyName);
_bsonReaderState = BsonReaderState.ReferenceId; _bsonReaderState = BsonReaderState.ReferenceId;
return true; return true;
} }
+3 -2
View File
@@ -27,6 +27,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Globalization; using System.Globalization;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if NET20 #if NET20
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
@@ -760,13 +761,13 @@ namespace Newtonsoft.Json
if (!ReadInternal()) if (!ReadInternal())
throw JsonReaderException.Create(this, "Unexpected end when reading bytes."); throw JsonReaderException.Create(this, "Unexpected end when reading bytes.");
if (Value.ToString() == "$type") if (Value.ToString() == JsonTypeReflector.TypePropertyName)
{ {
ReadInternal(); ReadInternal();
if (Value != null && Value.ToString().StartsWith("System.Byte[]")) if (Value != null && Value.ToString().StartsWith("System.Byte[]"))
{ {
ReadInternal(); ReadInternal();
if (Value.ToString() == "$value") if (Value.ToString() == JsonTypeReflector.ValuePropertyName)
{ {
return true; return true;
} }
@@ -25,6 +25,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json.Serialization;
#if NET20 #if NET20
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
#else #else
@@ -194,7 +195,7 @@ namespace Newtonsoft.Json.Schema
throw JsonException.Create(token, token.Path, "Expected object while parsing schema object, got {0}.".FormatWith(CultureInfo.InvariantCulture, token.Type)); throw JsonException.Create(token, token.Path, "Expected object while parsing schema object, got {0}.".FormatWith(CultureInfo.InvariantCulture, token.Type));
JToken referenceToken; JToken referenceToken;
if (schemaObject.TryGetValue(JsonSchemaConstants.ReferencePropertyName, out referenceToken)) if (schemaObject.TryGetValue(JsonTypeReflector.RefPropertyName, out referenceToken))
{ {
JsonSchema deferredSchema = new JsonSchema(); JsonSchema deferredSchema = new JsonSchema();
deferredSchema.DeferredReference = (string)referenceToken; deferredSchema.DeferredReference = (string)referenceToken;
@@ -63,8 +63,6 @@ namespace Newtonsoft.Json.Schema
public const string OptionValuePropertyName = "value"; public const string OptionValuePropertyName = "value";
public const string OptionLabelPropertyName = "label"; public const string OptionLabelPropertyName = "label";
public const string ReferencePropertyName = "$ref";
public static readonly IDictionary<string, JsonSchemaType> JsonSchemaTypeMapping = new Dictionary<string, JsonSchemaType> public static readonly IDictionary<string, JsonSchemaType> JsonSchemaTypeMapping = new Dictionary<string, JsonSchemaType>
{ {
{ "string", JsonSchemaType.String }, { "string", JsonSchemaType.String },
@@ -25,6 +25,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities; using Newtonsoft.Json.Utilities;
#if NET20 #if NET20
using Newtonsoft.Json.Utilities.LinqBridge; using Newtonsoft.Json.Utilities.LinqBridge;
@@ -52,7 +53,7 @@ namespace Newtonsoft.Json.Schema
if (schema.Id != null && _resolver.GetSchema(schema.Id) != null) if (schema.Id != null && _resolver.GetSchema(schema.Id) != null)
{ {
_writer.WriteStartObject(); _writer.WriteStartObject();
_writer.WritePropertyName(JsonSchemaConstants.ReferencePropertyName); _writer.WritePropertyName(JsonTypeReflector.RefPropertyName);
_writer.WriteValue(schema.Id); _writer.WriteValue(schema.Id);
_writer.WriteEndObject(); _writer.WriteEndObject();
} }
@@ -1948,10 +1948,10 @@ To fix this error either change the environment to be fully trusted, change the
{ {
switch (memberName) switch (memberName)
{ {
case "$type": case JsonTypeReflector.IdPropertyName:
case "$id": case JsonTypeReflector.RefPropertyName:
case "$ref": case JsonTypeReflector.TypePropertyName:
case "$values": case JsonTypeReflector.ArrayValuesPropertyName:
reader.Skip(); reader.Skip();
return true; return true;
} }