Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #194 from remcoros/master

special case Guid in DefaultActionResolver. fixes #182
  • Loading branch information...
commit 5a0c2411a4c1ce616a3a7145415ff7c38acc7be8 2 parents a26000f + f823ada
@davidfowl davidfowl authored
View
29 SignalR.Tests/DefaultActionResolverTest.cs
@@ -1,4 +1,5 @@
-using Newtonsoft.Json.Linq;
+using System;
+using Newtonsoft.Json.Linq;
using SignalR.Hubs;
using Xunit;
@@ -141,8 +142,23 @@ public void ResolveActionBindsComplexArrayArgument()
Assert.NotNull(complex.Address);
Assert.Equal("The street", complex.Address.Street);
Assert.Equal(34567, complex.Address.Zip);
- }
-
+ }
+
+ [Fact]
+ public void ResolveActionBindsGuid()
+ {
+ var resolver = new DefaultActionResolver();
+ var arg = "1d6a1d30-599f-4495-ace7-303fd87204bb";
+
+ var actionInfo = resolver.ResolveAction(typeof(TestHub),
+ "MethodWithGuid",
+ new object[] { arg });
+
+ Assert.NotNull(actionInfo);
+ var arg0 = (Guid)actionInfo.Arguments[0];
+ Assert.Equal(new Guid(arg), arg0);
+ }
+
private class TestDerivedHub : TestHub
{
public void FooDerived()
@@ -187,7 +203,12 @@ public void MethodWithArrayOfComplete(Complex[] complexes)
public void MethodWithComplex(Complex complex)
{
- }
+ }
+
+ public void MethodWithGuid(Guid guid)
+ {
+
+ }
}
public class Complex
View
5 SignalR/Hubs/DefaultActionResolver.cs
@@ -58,6 +58,11 @@ private object Bind(object value, Type type)
return value;
}
+ if (type == typeof(Guid))
+ {
+ return new Guid(value.ToString());
+ }
+
return JsonConvert.DeserializeObject(value.ToString(), type);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.