internal void BindHandler(ServiceBinderBase binder) { var method = new Method <byte[], byte[]>(this.MethodType, this.ServiceName, this.MethodName, MagicOnionMarshallers.ThroughMarshaller, MagicOnionMarshallers.ThroughMarshaller); switch (this.MethodType) { case MethodType.Unary: { var genericMethod = this.GetType() .GetMethod(nameof(UnaryServerMethod), BindingFlags.Instance | BindingFlags.NonPublic) ! .MakeGenericMethod(RequestType, UnwrappedResponseType); var handler = (UnaryServerMethod <byte[], byte[]>)genericMethod.CreateDelegate(typeof(UnaryServerMethod <byte[], byte[]>), this); binder.AddMethod(method, handler); } break; case MethodType.ClientStreaming: { var genericMethod = this.GetType() .GetMethod(nameof(ClientStreamingServerMethod), BindingFlags.Instance | BindingFlags.NonPublic) ! .MakeGenericMethod(RequestType, UnwrappedResponseType); var handler = (ClientStreamingServerMethod <byte[], byte[]>)genericMethod.CreateDelegate(typeof(ClientStreamingServerMethod <byte[], byte[]>), this); binder.AddMethod(method, handler); } break; case MethodType.ServerStreaming: { var genericMethod = this.GetType() .GetMethod(nameof(ServerStreamingServerMethod), BindingFlags.Instance | BindingFlags.NonPublic) ! .MakeGenericMethod(RequestType, UnwrappedResponseType); var handler = (ServerStreamingServerMethod <byte[], byte[]>)genericMethod.CreateDelegate(typeof(ServerStreamingServerMethod <byte[], byte[]>), this); binder.AddMethod(method, handler); } break; case MethodType.DuplexStreaming: { var genericMethod = this.GetType() .GetMethod(nameof(DuplexStreamingServerMethod), BindingFlags.Instance | BindingFlags.NonPublic) ! .MakeGenericMethod(RequestType, UnwrappedResponseType); var handler = (DuplexStreamingServerMethod <byte[], byte[]>)genericMethod.CreateDelegate(typeof(DuplexStreamingServerMethod <byte[], byte[]>), this); binder.AddMethod(method, handler); } break; default: throw new InvalidOperationException("Unknown RegisterType:" + this.MethodType); } }
public static void BindService(ServiceBinderBase serviceBinder, GreeterBase serviceImpl) { serviceBinder.AddMethod(__Method_SayHello, (UnaryServerMethod <global::Greet.HelloRequest, global::Greet.HelloReply>)null !); serviceBinder.AddMethod(__Method_SayHellos, (ServerStreamingServerMethod <global::Greet.HelloRequest, global::Greet.HelloReply>)null !); }