C#C
C#2y ago
Verdur

✅ Complicated error with C# SignalR client

Hi, I'm trying to receive base class in signalr using connection.on function. My base class has inherits and they all may be sent to the client.
Problem is in connection.on<T> method.
It converts whatever JSON serialized data comes to it straight to the
T
type, ignoring
T
's dervied types.
I have tested it by wrapping my Foo class in wrapper class Bar and passing it to the method:
c#
connection.On<Bar>(...)

This way, if I store Baz: Foo type in Bar and pass it to client, it will recieve Bar with
foo
field having Baz type.

Is there a way to make connection.on<T> convert incoming data not just to
T
, but to it's derivative too without using wrapper classes?
Was this page helpful?