-Updated Sandcastle

This commit is contained in:
James Newton-King
2013-10-17 10:50:02 +13:00
parent 9c322382a1
commit 56ee111b71
5 changed files with 75 additions and 79 deletions
@@ -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; }