/// <summary> /// Creates a new proxy instance for gRPC service contract <typeparamref name="TContract"/>. /// </summary> /// <typeparam name="TContract">The service contract type.</typeparam> /// <param name="callInvoker">The client-side RPC invocation.</param> /// <returns>The proxy for <typeparamref name="TContract"/>.</returns> public TContract CreateClient <TContract>(CallInvoker callInvoker) where TContract : class { callInvoker.AssertNotNull(nameof(callInvoker)); object factory; Interceptor interceptor; lock (_syncRoot) { var contractType = typeof(TContract); if (!_builderByContract.TryGetValue(contractType, out factory)) { factory = RegisterClient <TContract>(null, null); } _interceptorByContract.TryGetValue(contractType, out interceptor); } var builder = (IClientBuilder <TContract>)factory; if (interceptor != null) { callInvoker = callInvoker.Intercept(interceptor); } return(builder.Build(callInvoker)); }