-Add support for using implicit/explicit casts when converting a JSON property name to a dictionary value

-Fix DynamicReflectionDelegateFactory erroring when calling static methods
-Fix CustomCreationConverter to return null when converting a null JSON value
This commit is contained in:
JamesNK
2010-03-23 00:21:57 +00:00
parent 408a407105
commit 7f7cccd598
7 changed files with 214 additions and 8 deletions
@@ -27,10 +27,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using NUnit.Framework;
using Newtonsoft.Json.Utilities;
using Newtonsoft.Json.Tests.TestObjects;
using Newtonsoft.Json.Tests.Serialization;
namespace Newtonsoft.Json.Tests.Utilities
{
@@ -89,6 +91,22 @@ namespace Newtonsoft.Json.Tests.Utilities
setter(m, new Version());
}
[Test]
public void CreateStaticMethodCall()
{
MethodInfo castMethodInfo = typeof(JsonSerializerTest.DictionaryKey).GetMethod("op_Implicit", new[] { typeof(string) });
Assert.IsNotNull(castMethodInfo);
MethodCall<object, object> call = DynamicReflectionDelegateFactory.Instance.CreateMethodCall<object>(castMethodInfo);
object result = call(null, "First!");
Assert.IsNotNull(result);
JsonSerializerTest.DictionaryKey key = (JsonSerializerTest.DictionaryKey) result;
Assert.AreEqual("First!", key.Value);
}
}
}
#endif