Message Encode(IKMessageContext <TNodeId> context, IKMessage <TNodeId> message) { return(message switch { IKRequest <TNodeId> request => Encode(context, request), IKResponse <TNodeId> response => Encode(context, response), _ => throw new InvalidOperationException(), });
Message Encode(IKMessageContext <TNodeId> context, IKMessage <TNodeId> message) { if (message is IKRequest <TNodeId> request) { return(Encode(context, request)); } if (message is IKResponse <TNodeId> response) { return(Encode(context, response)); } throw new InvalidOperationException(); }
void Write(Utf8JsonWriter writer, IKMessageContext <TNodeId> context, IKMessage <TNodeId> message) { switch (message) { case IKRequest <TNodeId> request: Write(writer, context, request); break; case IKResponse <TNodeId> response: Write(writer, context, response); break; default: throw new InvalidOperationException(); } }