-Demo
-Changed build script to support NuGet profiles
This commit is contained in:
@@ -601,6 +601,41 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
// Admin
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImprovedDynamicLinqExample()
|
||||
{
|
||||
dynamic product = new JObject();
|
||||
product.ProductName = "Elbow Grease";
|
||||
product.Enabled = true;
|
||||
product.Price = 4.90m;
|
||||
product.StockCount = 9000;
|
||||
product.StockValue = 44100;
|
||||
|
||||
// All Elbow Grease must go sale!
|
||||
// 50% off price
|
||||
|
||||
product.Price = product.Price / 2;
|
||||
product.StockValue = product.StockCount * product.Price;
|
||||
product.ProductName = product.ProductName + " (SALE)";
|
||||
|
||||
string json = product.ToString();
|
||||
// {
|
||||
// "ProductName": "Elbow Grease (SALE)",
|
||||
// "Enabled": true,
|
||||
// "Price": 2.45,
|
||||
// "StockCount": 9000,
|
||||
// "StockValue": 22050.0
|
||||
// }
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""ProductName"": ""Elbow Grease (SALE)"",
|
||||
""Enabled"": true,
|
||||
""Price"": 2.45,
|
||||
""StockCount"": 9000,
|
||||
""StockValue"": 22050.0
|
||||
}", json);
|
||||
}
|
||||
|
||||
public class DynamicDictionary : DynamicObject
|
||||
{
|
||||
private readonly IDictionary<string, object> _values = new Dictionary<string, object>();
|
||||
|
||||
@@ -39,7 +39,7 @@ using System.Runtime.InteropServices;
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("4.2.0.0")]
|
||||
[assembly: AssemblyVersion("4.0.2.0")]
|
||||
#if !PocketPC
|
||||
[assembly: AssemblyFileVersion("4.2.13610.1823")]
|
||||
[assembly: AssemblyFileVersion("4.0.2.13622")]
|
||||
#endif
|
||||
|
||||
@@ -108,9 +108,9 @@ 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.2.0.0")]
|
||||
[assembly: AssemblyVersion("4.0.2.0")]
|
||||
#if !PocketPC
|
||||
[assembly: AssemblyFileVersion("4.2.13610.1823")]
|
||||
[assembly: AssemblyFileVersion("4.0.2.13622")]
|
||||
#endif
|
||||
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
@@ -21,12 +21,14 @@ namespace Newtonsoft.Json.Utilities
|
||||
if (objA == null && objB != null)
|
||||
return false;
|
||||
|
||||
// comparing an Int32 and Int64 both of the same value returns false
|
||||
// make types the same then compare
|
||||
if (objA.GetType() != objB.GetType())
|
||||
{
|
||||
if (ConvertUtils.IsInteger(objA) && ConvertUtils.IsInteger(objB))
|
||||
return Convert.ToDecimal(objA).Equals(Convert.ToDecimal(objB));
|
||||
return Convert.ToDecimal(objA, CultureInfo.CurrentCulture).Equals(Convert.ToDecimal(objB, CultureInfo.CurrentCulture));
|
||||
else if ((objA is double || objA is float || objA is decimal) && (objB is double || objB is float || objB is decimal))
|
||||
return MathUtils.ApproxEquals(Convert.ToDouble(objA), Convert.ToDouble(objB));
|
||||
return MathUtils.ApproxEquals(Convert.ToDouble(objA, CultureInfo.CurrentCulture), Convert.ToDouble(objB, CultureInfo.CurrentCulture));
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user