public IReadOnlyList <object> GenerateMethodStubs <TService>(IRpcServerCore rpcServer) where TService : class { var builder = new NetGrpcServiceStubBuilder <TService>(RpcBuilderUtil.GetServiceInfoFromType(typeof(TService)), null); var binder = new TestNetGrpcMethodBinder <TService>(); builder.GenerateOperationHandlers(rpcServer, binder); return(binder.stubs); }
private void BuildServiceStub <TService>(ServiceMethodProviderContext <TActivator> context) where TService : class { var typedContext = context as ServiceMethodProviderContext <NetGrpcServiceActivator <TService> >; if (typedContext == null) { // This shouldn't happen, since OnServiceMethodDiscovery should have already checked the type throw new InvalidCastException("Unexpected failure when casting to ServiceMethodProviderContext<NetGrpcServiceActivator<TService>>."); } var serviceInfo = this.rpcServer.ServiceDefinitionsProvider.GetRegisteredServiceInfo(typeof(TService)); if (serviceInfo == null) { throw new InvalidOperationException($"Service '{typeof(TService)}' not registered."); } var stubBuilder = new NetGrpcServiceStubBuilder <TService>( serviceInfo, this.serviceProvider.GetService <IOptions <RpcServiceOptions <TService> > >()?.Value); stubBuilder.Bind(this.rpcServer, typedContext); }