Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed the BinderHelper to detect IDictionary inputs and return them…

… unmodified.
  • Loading branch information...
commit 252147b3b773a7c1af66825b8bb09655f3e0278a 1 parent 6bdb3d1
@kppullin kppullin authored
View
9 Simple.Data.UnitTest/BinderHelperTest.cs
@@ -26,6 +26,15 @@ public void ArgumentsToDictionaryShouldApplyOrdinalNamesToFirstArguments()
var actual = binder.ArgumentsToDictionary(new object[] { 1, 2 });
Assert.AreEqual("_0", actual.First().Key);
}
+
+ [Test]
+ public void ArgumentsToDictionaryShouldReturnInputParameterWhenInputParameterIsDictionary()
+ {
+ var binder = new TestInvokeMemberBinder("Test", false, new CallInfo(1, "Foo"));
+ var input = new Dictionary<string, object> { { "Test1", 1 }, { "Test2", 2 } };
+ var actual = binder.ArgumentsToDictionary(new object[] { input });
+ Assert.AreEqual(input["Test2"], actual["Test2"]);
+ }
}
class TestInvokeMemberBinder : InvokeMemberBinder
View
6 Simple.Data/BinderHelper.cs
@@ -21,7 +21,11 @@ static class BinderHelper
public static IDictionary<string, object> ArgumentsToDictionary(this InvokeMemberBinder binder, IEnumerable<object> args)
{
- return args.Reverse()
+ var argsArray = args.ToArray();
+ if (argsArray.Length == 1 && argsArray[0] is IDictionary<string, object>)
+ return (IDictionary<string, object>)argsArray[0];
+
+ return argsArray.Reverse()
.Zip(binder.CallInfo.ArgumentNames.Reverse().ExtendInfinite(), (v, k) => new KeyValuePair<string, object>(k, v))
.Reverse()
.Select((kvp, i) => kvp.Key == null ? new KeyValuePair<string, object>("_" + i.ToString(), kvp.Value) : kvp)
Please sign in to comment.
Something went wrong with that request. Please try again.