I\'m want to serialize derived type as explained here but for signalR I want to implement my custom converter derived from JsonConverter
I added it to signalR as f
This has been driving me nuts for hours. Thanks to halter73's comment I was able to come up with a workaround for the problem in my special situation: I need the pipeline to create interface instances for me which does not work out of the box. So the solution was the following:
class CustomResolver : Microsoft.AspNet.SignalR.Hubs.DefaultParameterResolver
{
public override object ResolveParameter( Microsoft.AspNet.SignalR.Hubs.ParameterDescriptor descriptor, Microsoft.AspNet.SignalR.Json.IJsonValue value )
{
if( descriptor.ParameterType.IsInterface )
{
object TargetObject = <Create the object instance here>
return value.ConvertTo( TargetObject.GetType() );
}
else
{
return value.ConvertTo( descriptor.ParameterType );
}
}
}
Then before you call
WebApp.Start()
Register this new parameter resolver with:
GlobalHost.DependencyResolver.Register( typeof( Microsoft.AspNet.SignalR.Hubs.IParameterResolver ), () => new CustomResolver() );