-Updated Sandcastle
This commit is contained in:
@@ -75,4 +75,4 @@ using System.Security;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("4.5.0.0")]
|
||||
[assembly: AssemblyFileVersion("5.0.7.16613")]
|
||||
[assembly: AssemblyFileVersion("5.0.8.16617")]
|
||||
|
||||
@@ -84,17 +84,21 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
public void DeserializeListInterface()
|
||||
{
|
||||
string json = @"[
|
||||
""One"",
|
||||
""II"",
|
||||
""3""
|
||||
]";
|
||||
'Volibear',
|
||||
'Teemo',
|
||||
'Katarina'
|
||||
]";
|
||||
|
||||
IImmutableList<string> l = JsonConvert.DeserializeObject<IImmutableList<string>>(json);
|
||||
// what sorcery is this?!
|
||||
IImmutableList<string> champions = JsonConvert.DeserializeObject<IImmutableList<string>>(json);
|
||||
|
||||
Assert.AreEqual(3, l.Count);
|
||||
Assert.AreEqual("One", l[0]);
|
||||
Assert.AreEqual("II", l[1]);
|
||||
Assert.AreEqual("3", l[2]);
|
||||
Console.WriteLine(champions[0]);
|
||||
// Volibear
|
||||
|
||||
Assert.AreEqual(3, champions.Count);
|
||||
Assert.AreEqual("Volibear", champions[0]);
|
||||
Assert.AreEqual("Teemo", champions[1]);
|
||||
Assert.AreEqual("Katarina", champions[2]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -135,6 +135,40 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
|
||||
}
|
||||
|
||||
public class CustomerInvoice
|
||||
{
|
||||
// we're only modifing the tax rate
|
||||
public decimal TaxRate { get; set; }
|
||||
|
||||
// everything else gets stored here
|
||||
[JsonExtensionData]
|
||||
private IDictionary<string, JToken> _additionalData;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtensionDataExample()
|
||||
{
|
||||
string json = @"{
|
||||
'HourlyRate': 150,
|
||||
'Hours': 40,
|
||||
'TaxRate': 0.125
|
||||
}";
|
||||
|
||||
var invoice = JsonConvert.DeserializeObject<CustomerInvoice>(json);
|
||||
|
||||
// increase tax to 15%
|
||||
invoice.TaxRate = 0.15m;
|
||||
|
||||
string result = JsonConvert.SerializeObject(invoice);
|
||||
// {
|
||||
// 'TaxRate': 0.15,
|
||||
// 'HourlyRate': 150,
|
||||
// 'Hours': 40
|
||||
// }
|
||||
|
||||
Assert.AreEqual(@"{""TaxRate"":0.15,""HourlyRate"":150,""Hours"":40}", result);
|
||||
}
|
||||
|
||||
public class ExtensionDataTestClass
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
@@ -92,6 +92,6 @@ using System.Security;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("4.5.0.0")]
|
||||
[assembly: AssemblyFileVersion("5.0.7.16613")]
|
||||
[assembly: AssemblyFileVersion("5.0.8.16617")]
|
||||
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
Reference in New Issue
Block a user