public LanguageServiceClientImpl(LanguageService.LanguageServiceClient grpcClient, LanguageServiceSettings settings) { this.GrpcClient = grpcClient; LanguageServiceSettings effectiveSettings = settings ?? LanguageServiceSettings.GetDefault(); _clientHelper = new ClientHelper(effectiveSettings); _callAnalyzeSentiment = _clientHelper.BuildApiCall <AnalyzeSentimentRequest, AnalyzeSentimentResponse>( GrpcClient.AnalyzeSentimentAsync, GrpcClient.AnalyzeSentiment, effectiveSettings.AnalyzeSentimentSettings); _callAnalyzeEntities = _clientHelper.BuildApiCall <AnalyzeEntitiesRequest, AnalyzeEntitiesResponse>( GrpcClient.AnalyzeEntitiesAsync, GrpcClient.AnalyzeEntities, effectiveSettings.AnalyzeEntitiesSettings); _callAnnotateText = _clientHelper.BuildApiCall <AnnotateTextRequest, AnnotateTextResponse>( GrpcClient.AnnotateTextAsync, GrpcClient.AnnotateText, effectiveSettings.AnnotateTextSettings); }
/// <summary> /// Wrap a GRPC LanguageService client for more convenient use. /// </summary> /// <param name="grpcClient">A GRPC client to wrap.</param> /// <param name="settings"> /// An optional <see cref="LanguageServiceSettings"/> to configure this wrapper. /// If null or not specified, then the default settings are used. /// </param> /// <returns>A <see cref="LanguageServiceClient"/> that wraps the specified GRPC client.</returns> public static LanguageServiceClient ToClient( this LanguageService.LanguageServiceClient grpcClient, LanguageServiceSettings settings = null ) => new LanguageServiceClientImpl(grpcClient, settings);
/// <summary> /// Creates a <see cref="LanguageServiceClient"/> which uses the specified channel for remote operations. /// </summary> /// <param name="channel">The <see cref="Channel"/> for remote operations. Must not be null.</param> /// <param name="settings">Optional <see cref="LanguageServiceSettings"/>.</param> /// <returns>The created <see cref="LanguageServiceClient"/>.</returns> public static LanguageServiceClient Create(Channel channel, LanguageServiceSettings settings = null) { GaxPreconditions.CheckNotNull(channel, nameof(channel)); LanguageService.LanguageServiceClient grpcClient = new LanguageService.LanguageServiceClient(channel); return(new LanguageServiceClientImpl(grpcClient, settings)); }