Verdur
Check whether list of generics contains a type, that implements interface
Hello, I need to perform sophisticated generic type constraint.
I have following class to store multiple generics in my class, they are added to class after each method call:
And after calling few methods I get following type:
I have a function that accepts
Builder<IConst<TLeft, TRight>>
and I need generic constraint that will accept only those Builder
's, which have both IWithFoo
and IWithBar
somewhere inside their IConst<TLeft, TRight>
.
Something like this:
I tried another approach where I specified that Build<T>
accepts T where T : IWithBar, IWithFoo
, but that would require ICons<TLeft, TRight>
to implement TLeft
and TRight
, which I was answered is not possible (here: https://discord.com/channels/143867839282020352/1241306845940027472)1 replies
✅ 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:
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?22 replies