-Formatting
-Build
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -3,6 +3,6 @@
|
||||
"net45": {}
|
||||
},
|
||||
"runtimes": {
|
||||
"win-anycpu": {}
|
||||
"win": {}
|
||||
}
|
||||
}
|
||||
@@ -164,4 +164,4 @@ namespace Newtonsoft.Json.TestConsole
|
||||
Console.WriteLine("Finished. Total seconds: " + sw.Elapsed.TotalSeconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
|
||||
[assembly: AssemblyTitle("Json.NET Test Console")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
@@ -42,9 +43,11 @@ using System.Runtime.InteropServices;
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
|
||||
[assembly: Guid("bf0cc842-d368-4800-9614-b5abcc736110")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
@@ -56,5 +59,6 @@ using System.Runtime.InteropServices;
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("7.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("7.0.2.18802")]
|
||||
[assembly: AssemblyFileVersion("7.0.2.18802")]
|
||||
@@ -920,7 +920,9 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
largeStringBuilder.Append("-");
|
||||
}
|
||||
|
||||
largeStringBuilder.Append(i.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
@@ -1606,6 +1608,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
|
||||
#if !(NET20 || NET35)
|
||||
public bool BindToNameCalled { get; set; }
|
||||
|
||||
public override void BindToName(Type serializedType, out string assemblyName, out string typeName)
|
||||
{
|
||||
BindToNameCalled = true;
|
||||
@@ -1677,7 +1680,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
BsonReader reader = new BsonReader(new MemoryStream(bytes));
|
||||
Assert.IsTrue(reader.Read());
|
||||
Assert.IsTrue(reader.Read());
|
||||
|
||||
|
||||
Assert.IsTrue(reader.Read());
|
||||
Assert.AreEqual(JsonToken.Bytes, reader.TokenType);
|
||||
Assert.AreEqual(typeof(Guid), reader.ValueType);
|
||||
|
||||
@@ -301,7 +301,9 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
largeStringBuilder.Append("-");
|
||||
}
|
||||
|
||||
largeStringBuilder.Append(i.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
@@ -483,7 +485,6 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
// 6D-61-6C-6C-00-02-31-00-07-00-00-00-4D-65-64-69-75-6D-
|
||||
// 00-02-32-00-06-00-00-00-4C-61-72-67-65-00-00-00
|
||||
|
||||
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
// deserialize product from BSON
|
||||
@@ -493,7 +494,6 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
Console.WriteLine(deserializedProduct.Name);
|
||||
// Carlos' Spicy Wieners
|
||||
|
||||
|
||||
Assert.AreEqual("Carlos' Spicy Wieners", deserializedProduct.Name);
|
||||
Assert.AreEqual(9.95m, deserializedProduct.Price);
|
||||
Assert.AreEqual(3, deserializedProduct.Sizes.Length);
|
||||
@@ -745,10 +745,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
|
||||
BsonWriter writer = new BsonWriter(ms);
|
||||
|
||||
ExceptionAssert.Throws<JsonWriterException>(() =>
|
||||
{
|
||||
serializer.Serialize(writer, b);
|
||||
}, "Error writing Binary value. BSON must start with an Object or Array. Path ''.");
|
||||
ExceptionAssert.Throws<JsonWriterException>(() => { serializer.Serialize(writer, b); }, "Error writing Binary value. BSON must start with an Object or Array. Path ''.");
|
||||
}
|
||||
|
||||
public class GuidTestClass
|
||||
|
||||
@@ -43,6 +43,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
@@ -36,6 +36,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
@@ -590,4 +590,5 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -508,7 +508,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
Assert.AreEqual(new System.Data.SqlTypes.SqlDateTime(2015, 11, 28), ds.TestTable[0].DateTimeValue);
|
||||
Assert.AreEqual(System.Data.SqlTypes.SqlDateTime.Null, ds.TestTable[1].DateTimeValue);
|
||||
|
||||
|
||||
string json2 = JsonConvert.SerializeObject(ds, Formatting.Indented, new SqlDateTimeConverter());
|
||||
|
||||
StringAssert.AreEqual(json, json2);
|
||||
@@ -524,20 +524,29 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.Value == null || reader.Value == DBNull.Value)
|
||||
{
|
||||
return System.Data.SqlTypes.SqlDateTime.Null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new System.Data.SqlTypes.SqlDateTime((DateTime)serializer.Deserialize(reader));
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
if (((System.Data.SqlTypes.SqlDateTime)value).IsNull)
|
||||
{
|
||||
writer.WriteNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteValue(((System.Data.SqlTypes.SqlDateTime)value).Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -300,4 +300,5 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -40,6 +40,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
@@ -256,9 +256,13 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
// if the current timezone is utc then local already equals utc
|
||||
if (offset == TimeSpan.Zero)
|
||||
{
|
||||
Assert.AreEqual(json, json2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.AreNotEqual(json, json2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -227,9 +227,13 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
{
|
||||
DateTime? d = (DateTime?)value;
|
||||
if (d == null)
|
||||
{
|
||||
writer.WriteNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteValue(d.Value.Ticks);
|
||||
}
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
|
||||
@@ -13,6 +13,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Converters
|
||||
@@ -24,7 +25,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
public void SerializeUsingInternalConverter()
|
||||
{
|
||||
DefaultContractResolver contractResolver = new DefaultContractResolver();
|
||||
JsonObjectContract contract = (JsonObjectContract) contractResolver.ResolveContract(typeof (KeyValuePair<string, int>));
|
||||
JsonObjectContract contract = (JsonObjectContract)contractResolver.ResolveContract(typeof(KeyValuePair<string, int>));
|
||||
|
||||
Assert.AreEqual(typeof(KeyValuePairConverter), contract.InternalConverter.GetType());
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
@@ -500,7 +500,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
Assert.AreEqual(DuplicateNameEnum.foo_bar, o.Value);
|
||||
Assert.AreEqual(DuplicateNameEnum2.FooBar, o.Value2);
|
||||
|
||||
}, "Type 'Newtonsoft.Json.Tests.Converters.DuplicateNameEnum' contains two members 'foo_bar' 'and 'FooBar' with the same name 'foo_bar'. Multiple members with the same name in one type are not supported. Consider changing one of the member names using EnumMemberAttribute attribute.");
|
||||
}
|
||||
#endif
|
||||
@@ -512,6 +511,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
{
|
||||
[DataMember]
|
||||
public DuplicateNameEnum Value { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public DuplicateNameEnum2 Value2 { get; set; }
|
||||
}
|
||||
@@ -521,10 +521,13 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
{
|
||||
[EnumMember]
|
||||
first = 0,
|
||||
|
||||
[EnumMember]
|
||||
foo_bar = 1,
|
||||
|
||||
[EnumMember(Value = "foo_bar")]
|
||||
FooBar = 2,
|
||||
|
||||
[EnumMember]
|
||||
foo_bar_NOT_USED = 3
|
||||
}
|
||||
@@ -534,10 +537,13 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
{
|
||||
[EnumMember]
|
||||
first = 0,
|
||||
|
||||
[EnumMember(Value = "foo_bar")]
|
||||
FooBar = 1,
|
||||
|
||||
[EnumMember]
|
||||
foo_bar = 2,
|
||||
|
||||
[EnumMember(Value = "TEST")]
|
||||
foo_bar_NOT_USED = 3
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
@@ -53,6 +53,7 @@ using Newtonsoft.Json.Utilities;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if !NET20
|
||||
using System.Xml.Linq;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Converters
|
||||
@@ -103,7 +104,9 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
reader.Read();
|
||||
XmlNodeConverter converter = new XmlNodeConverter();
|
||||
if (deserializeRootElementName != null)
|
||||
{
|
||||
converter.DeserializeRootElementName = deserializeRootElementName;
|
||||
}
|
||||
|
||||
XmlNode node = (XmlNode)converter.ReadJson(reader, typeof(XmlDocument), null, new JsonSerializer());
|
||||
|
||||
@@ -116,7 +119,9 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
string linqXmlText = d.ToString(SaveOptions.DisableFormatting);
|
||||
if (d.Declaration != null)
|
||||
{
|
||||
linqXmlText = d.Declaration + linqXmlText;
|
||||
}
|
||||
|
||||
Assert.AreEqual(xmlText, linqXmlText);
|
||||
#endif
|
||||
@@ -238,7 +243,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
var result = xmlDocument.FirstChild.ChildNodes.Cast<XmlNode>().ToArray();
|
||||
|
||||
var json = JsonConvert.SerializeObject(result, Formatting.Indented); // <--- fails here with the cast message
|
||||
var json = JsonConvert.SerializeObject(result, Formatting.Indented); // <--- fails here with the cast message
|
||||
|
||||
StringAssert.AreEqual(@"[
|
||||
{
|
||||
@@ -275,7 +280,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
var result = xmlDocument.Root.Nodes().ToArray();
|
||||
|
||||
var json = JsonConvert.SerializeObject(result, Formatting.Indented); // <--- fails here with the cast message
|
||||
var json = JsonConvert.SerializeObject(result, Formatting.Indented); // <--- fails here with the cast message
|
||||
|
||||
StringAssert.AreEqual(@"[
|
||||
{
|
||||
@@ -446,10 +451,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
}
|
||||
}";
|
||||
ExceptionAssert.Throws<JsonSerializationException>(
|
||||
() =>
|
||||
{
|
||||
JsonConvert.DeserializeXmlNode(json);
|
||||
},
|
||||
() => { JsonConvert.DeserializeXmlNode(json); },
|
||||
"JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName. Path 'Email', line 3, position 13.");
|
||||
}
|
||||
|
||||
@@ -553,7 +555,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
Assert.AreEqual(@"{""?xml-stylesheet"":""href=\""classic.xsl\"" type=\""text/xml\""""}", jsonText);
|
||||
|
||||
|
||||
// XmlProcessingInstruction
|
||||
XmlCDataSection cDataSection = doc.CreateCDataSection("<Kiwi>true</Kiwi>");
|
||||
|
||||
@@ -561,7 +562,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
Assert.AreEqual(@"{""#cdata-section"":""<Kiwi>true</Kiwi>""}", jsonText);
|
||||
|
||||
|
||||
// XmlElement
|
||||
XmlElement element = doc.CreateElement("xs", "Choice", "http://www.w3.org/2001/XMLSchema");
|
||||
element.SetAttributeNode(doc.CreateAttribute("msdata", "IsDataSet", "urn:schemas-microsoft-com:xml-msdata"));
|
||||
@@ -711,7 +711,10 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
public class Utf8StringWriter : StringWriter
|
||||
{
|
||||
public override Encoding Encoding { get { return Encoding.UTF8; } }
|
||||
public override Encoding Encoding
|
||||
{
|
||||
get { return Encoding.UTF8; }
|
||||
}
|
||||
|
||||
public Utf8StringWriter(StringBuilder sb) : base(sb)
|
||||
{
|
||||
@@ -1303,7 +1306,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
StringAssert.AreEqual(expected, jsonText);
|
||||
|
||||
XmlDocument newDoc = (XmlDocument)DeserializeXmlNode(jsonText);
|
||||
Assert.AreEqual(@"<span class=""vevent""><a class=""url"" href=""http://www.web2con.com/""><!-- Hi --><span>Text</span></a><!-- Hi! --></span>", newDoc.InnerXml);
|
||||
Assert.AreEqual(@"<span class=""vevent""><a class=""url"" href=""http://www.web2con.com/""><!-- Hi --><span>Text</span></a><!-- Hi! --></span>", newDoc.InnerXml);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -1948,7 +1951,9 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
{
|
||||
XmlDocument doc = (XmlDocument)serializer.Deserialize(reader, typeof(XmlDocument));
|
||||
if (reader.Read() && reader.TokenType != JsonToken.Comment)
|
||||
{
|
||||
throw new JsonSerializationException("Additional text found in JSON string after finishing deserializing object.");
|
||||
}
|
||||
using (XmlWriter writer = XmlWriter.Create(xml))
|
||||
{
|
||||
doc.Save(writer);
|
||||
@@ -2583,4 +2588,5 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -40,6 +40,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests
|
||||
@@ -113,8 +114,8 @@ namespace Newtonsoft.Json.Tests
|
||||
// create hex string from value
|
||||
HtmlColor color = (HtmlColor)value;
|
||||
string hexString = color.Red.ToString("X2")
|
||||
+ color.Green.ToString("X2")
|
||||
+ color.Blue.ToString("X2");
|
||||
+ color.Green.ToString("X2")
|
||||
+ color.Blue.ToString("X2");
|
||||
|
||||
// write value to json
|
||||
writer.WriteValue("#" + hexString);
|
||||
@@ -450,10 +451,13 @@ namespace Newtonsoft.Json.Tests
|
||||
public class House1
|
||||
{
|
||||
public string StreetAddress { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int Bedrooms { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public decimal FloorArea { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DateTime BuildDate { get; set; }
|
||||
}
|
||||
@@ -463,6 +467,7 @@ namespace Newtonsoft.Json.Tests
|
||||
{
|
||||
[JsonProperty]
|
||||
public string StreetAddress { get; set; }
|
||||
|
||||
public int Bedrooms { get; set; }
|
||||
public decimal FloorArea { get; set; }
|
||||
public DateTime BuildDate { get; set; }
|
||||
@@ -473,6 +478,7 @@ namespace Newtonsoft.Json.Tests
|
||||
{
|
||||
[JsonProperty("address")]
|
||||
public string StreetAddress { get; set; }
|
||||
|
||||
public int Bedrooms { get; set; }
|
||||
public decimal FloorArea { get; set; }
|
||||
public DateTime BuildDate { get; set; }
|
||||
@@ -483,8 +489,10 @@ namespace Newtonsoft.Json.Tests
|
||||
{
|
||||
[JsonProperty("address", Order = 2)]
|
||||
public string StreetAddress { get; set; }
|
||||
|
||||
public int Bedrooms { get; set; }
|
||||
public decimal FloorArea { get; set; }
|
||||
|
||||
[JsonProperty("buildDate", Order = 1)]
|
||||
public DateTime BuildDate { get; set; }
|
||||
}
|
||||
@@ -494,8 +502,10 @@ namespace Newtonsoft.Json.Tests
|
||||
{
|
||||
[JsonProperty("address", Order = 2)]
|
||||
public string StreetAddress { get; set; }
|
||||
|
||||
public int Bedrooms { get; set; }
|
||||
public decimal FloorArea { get; set; }
|
||||
|
||||
[JsonProperty("buildDate", Order = 1)]
|
||||
[JsonConverter(typeof(JavaScriptDateTimeConverter))]
|
||||
public DateTime BuildDate { get; set; }
|
||||
|
||||
@@ -183,4 +183,5 @@ namespace Newtonsoft.Json.Tests.Documentation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -186,5 +186,6 @@ namespace Newtonsoft.Json.Tests.Documentation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
||||
#endif
|
||||
@@ -92,7 +92,9 @@ namespace Newtonsoft.Json.Tests.Documentation
|
||||
|
||||
// this will only be called once and then cached
|
||||
if (objectType == typeof(DateTime) || objectType == typeof(DateTimeOffset))
|
||||
{
|
||||
contract.Converter = new JavaScriptDateTimeConverter();
|
||||
}
|
||||
|
||||
return contract;
|
||||
}
|
||||
|
||||
@@ -113,9 +113,13 @@ namespace Newtonsoft.Json.Tests.Documentation
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.Value != null)
|
||||
{
|
||||
Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Token: {0}", reader.TokenType);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: StartObject
|
||||
|
||||
@@ -34,6 +34,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Bson
|
||||
|
||||
@@ -34,6 +34,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Bson
|
||||
|
||||
@@ -35,6 +35,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Bson
|
||||
|
||||
@@ -36,13 +36,15 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
#if !(DNXCORE50 || NET20)
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
{
|
||||
#region Types
|
||||
|
||||
#region Types
|
||||
public class XmlJsonReader : JsonReader
|
||||
{
|
||||
private readonly Stack<JTokenType> _stateStack;
|
||||
@@ -65,7 +67,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
public override bool Read()
|
||||
{
|
||||
if (HandleValueType())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
while (_reader.Read())
|
||||
{
|
||||
@@ -74,7 +78,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
case XmlNodeType.Element:
|
||||
string typeName = _reader.GetAttribute("type");
|
||||
if (typeName == null)
|
||||
{
|
||||
throw new Exception("No type specified.");
|
||||
}
|
||||
|
||||
_valueType = (JTokenType)Enum.Parse(typeof(JTokenType), typeName, true);
|
||||
|
||||
@@ -100,25 +106,33 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
SetToken(JsonToken.EndObject);
|
||||
_stateStack.Pop();
|
||||
if (PeekState() == JTokenType.Property)
|
||||
{
|
||||
_stateStack.Pop();
|
||||
}
|
||||
return true;
|
||||
case JTokenType.Array:
|
||||
SetToken(JsonToken.EndArray);
|
||||
_stateStack.Pop();
|
||||
if (PeekState() == JTokenType.Property)
|
||||
{
|
||||
_stateStack.Pop();
|
||||
}
|
||||
return true;
|
||||
case JTokenType.Constructor:
|
||||
SetToken(JsonToken.EndConstructor);
|
||||
_stateStack.Pop();
|
||||
if (PeekState() == JTokenType.Property)
|
||||
{
|
||||
_stateStack.Pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
_stateStack.Pop();
|
||||
if (PeekState() == JTokenType.Property)
|
||||
{
|
||||
_stateStack.Pop();
|
||||
}
|
||||
|
||||
break;
|
||||
case XmlNodeType.Text:
|
||||
@@ -168,7 +182,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
_valueType = null;
|
||||
|
||||
if (PeekState() == JTokenType.Property)
|
||||
{
|
||||
_stateStack.Pop();
|
||||
}
|
||||
return true;
|
||||
case JTokenType.Object:
|
||||
SetToken(JsonToken.StartObject);
|
||||
@@ -183,7 +199,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
case JTokenType.Constructor:
|
||||
string constructorName = _reader.GetAttribute("name");
|
||||
if (constructorName == null)
|
||||
{
|
||||
throw new Exception("No constructor name specified.");
|
||||
}
|
||||
|
||||
SetToken(JsonToken.StartConstructor, constructorName);
|
||||
_stateStack.Push(JTokenType.Constructor);
|
||||
@@ -196,7 +214,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
public override int? ReadAsInt32()
|
||||
{
|
||||
if (!Read())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (Value != null) ? (int?)Convert.ToInt32(Value) : null;
|
||||
}
|
||||
@@ -204,7 +224,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
public override string ReadAsString()
|
||||
{
|
||||
if (!Read())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string)Value;
|
||||
}
|
||||
@@ -212,7 +234,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
public override byte[] ReadAsBytes()
|
||||
{
|
||||
if (!Read())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (byte[])Value;
|
||||
}
|
||||
@@ -220,7 +244,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
public override decimal? ReadAsDecimal()
|
||||
{
|
||||
if (!Read())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (Value != null) ? (decimal?)Convert.ToDecimal(Value) : null;
|
||||
}
|
||||
@@ -228,7 +254,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
public override DateTime? ReadAsDateTime()
|
||||
{
|
||||
if (!Read())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (Value != null) ? (DateTime?)Convert.ToDateTime(Value) : null;
|
||||
}
|
||||
@@ -236,12 +264,14 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
public override DateTimeOffset? ReadAsDateTimeOffset()
|
||||
{
|
||||
if (!Read())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (Value != null) ? (DateTimeOffset?)Convert.ToDateTime(Value) : null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
[TestFixture]
|
||||
public class CustomJsonReader : TestFixtureBase
|
||||
@@ -249,7 +279,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
#region Usage
|
||||
#region Usage
|
||||
string xml = @"<Root type=""Object"">
|
||||
<Null type=""Null"" />
|
||||
<String type=""String"">This is a string!</String>
|
||||
@@ -308,7 +338,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
// "Constructor": new Date(2000, 12, 30)
|
||||
//}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
using (XmlReader xmlReader = XmlReader.Create(new StringReader(xml), new XmlReaderSettings { IgnoreWhitespace = true }))
|
||||
using (XmlJsonReader reader = new XmlJsonReader(xmlReader))
|
||||
|
||||
@@ -36,13 +36,15 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
#if !(DNXCORE50 || NET20)
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
{
|
||||
#region Types
|
||||
|
||||
#region Types
|
||||
public class XmlJsonWriter : JsonWriter
|
||||
{
|
||||
private readonly XmlWriter _writer;
|
||||
@@ -234,9 +236,13 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
base.WriteStartArray();
|
||||
|
||||
if (isStart)
|
||||
{
|
||||
WriteValueElement("Root", JTokenType.Array);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteValueElement(JTokenType.Array);
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteStartObject()
|
||||
@@ -246,9 +252,13 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
base.WriteStartObject();
|
||||
|
||||
if (isStart)
|
||||
{
|
||||
WriteValueElement("Root", JTokenType.Object);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteValueElement(JTokenType.Object);
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteStartConstructor(string name)
|
||||
@@ -258,9 +268,13 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
base.WriteStartConstructor(name);
|
||||
|
||||
if (isStart)
|
||||
{
|
||||
WriteValueElement("Root", JTokenType.Constructor);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteValueElement(JTokenType.Constructor);
|
||||
}
|
||||
|
||||
_writer.WriteAttributeString("name", name);
|
||||
}
|
||||
@@ -306,7 +320,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
[TestFixture]
|
||||
public class CustomJsonWriter : TestFixtureBase
|
||||
@@ -314,17 +328,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
#region Usage
|
||||
#region Usage
|
||||
var user = new
|
||||
{
|
||||
Name = "James",
|
||||
Age = 30,
|
||||
Enabled = true,
|
||||
Roles = new[]
|
||||
{
|
||||
"Publisher",
|
||||
"Administrator"
|
||||
}
|
||||
{
|
||||
"Publisher",
|
||||
"Administrator"
|
||||
}
|
||||
};
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
@@ -348,7 +362,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
// <Item type="String">Administrator</Item>
|
||||
// </Roles>
|
||||
//</Root>
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
sw = new StringWriter();
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
@@ -59,9 +60,13 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.Value != null)
|
||||
{
|
||||
Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Token: {0}", reader.TokenType);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: StartObject
|
||||
|
||||
+3
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
@@ -61,7 +62,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
while (true)
|
||||
{
|
||||
if (!reader.Read())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
Role role = serializer.Deserialize<Role>(reader);
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Json
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -38,6 +38,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -38,6 +38,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -35,6 +35,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
@@ -62,7 +63,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
{
|
||||
Console.Write(reader.TokenType);
|
||||
if (reader.Value != null)
|
||||
{
|
||||
Console.Write(" - " + reader.Value);
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -41,6 +41,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -59,7 +59,6 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
o["age"] = 59;
|
||||
o["employer"] = "Bill & Melinda Gates Foundation";
|
||||
|
||||
|
||||
HashSet<string> changedProperties = o.Annotation<HashSet<string>>();
|
||||
// age
|
||||
// employer
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -30,6 +30,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -38,6 +38,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -40,6 +40,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -38,6 +38,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -38,6 +38,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -38,6 +38,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -35,6 +35,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -34,6 +34,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -41,6 +41,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -34,6 +34,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -34,6 +34,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -35,6 +35,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -34,6 +34,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
|
||||
|
||||
@@ -82,4 +82,5 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
||||
@@ -62,4 +62,5 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
||||
@@ -72,4 +72,5 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
||||
@@ -71,4 +71,5 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
||||
@@ -64,4 +64,5 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
||||
+1
@@ -84,4 +84,5 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
||||
@@ -50,4 +50,5 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
||||
@@ -80,4 +80,5 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
||||
@@ -55,4 +55,5 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
||||
@@ -38,6 +38,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
@@ -38,6 +38,7 @@ using NUnit.Framework;
|
||||
using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
#else
|
||||
using System.Linq;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
@@ -34,6 +34,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
#if !(DNXCORE50 || NET20 || NET35)
|
||||
@@ -43,7 +44,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
[TestFixture]
|
||||
public class CustomTraceWriter : TestFixtureBase
|
||||
{
|
||||
#region Types
|
||||
#region Types
|
||||
public class NLogTraceWriter : ITraceWriter
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetLogger("NLogTraceWriter");
|
||||
@@ -84,12 +85,12 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
#region Usage
|
||||
#region Usage
|
||||
IList<string> countries = new List<string>
|
||||
{
|
||||
"New Zealand",
|
||||
@@ -110,7 +111,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
// "Denmark",
|
||||
// "China"
|
||||
// ]
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
Assert.AreEqual(@"[
|
||||
""New Zealand"",
|
||||
|
||||
+1
@@ -35,6 +35,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
@@ -32,6 +32,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
@@ -37,6 +37,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
+3
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
@@ -52,7 +53,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
public Website(Website website)
|
||||
{
|
||||
if (website == null)
|
||||
{
|
||||
throw new ArgumentNullException("website");
|
||||
}
|
||||
|
||||
Url = website.Url;
|
||||
}
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
@@ -35,6 +35,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
@@ -32,6 +32,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
@@ -32,6 +32,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
+2
@@ -63,7 +63,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
// use Autofac to create types that have been registered with it
|
||||
if (_container.IsRegistered(objectType))
|
||||
{
|
||||
contract.DefaultCreator = () => _container.Resolve(objectType);
|
||||
}
|
||||
|
||||
return contract;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
@@ -54,7 +55,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
get
|
||||
{
|
||||
if (_roles == null)
|
||||
{
|
||||
throw new Exception("Roles not loaded!");
|
||||
}
|
||||
|
||||
return _roles;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
@@ -32,6 +32,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user