private LanguageServiceSettings(LanguageServiceSettings existing) : base(existing) { GaxPreconditions.CheckNotNull(existing, nameof(existing)); AnalyzeSentimentSettings = existing.AnalyzeSentimentSettings; AnalyzeEntitiesSettings = existing.AnalyzeEntitiesSettings; AnalyzeSyntaxSettings = existing.AnalyzeSyntaxSettings; AnnotateTextSettings = existing.AnnotateTextSettings; }
/// <summary> /// Constructs a client wrapper for the LanguageService service, with the specified gRPC client and settings. /// </summary> /// <param name="grpcClient">The underlying gRPC client.</param> /// <param name="settings">The base <see cref="LanguageServiceSettings"/> used within this client </param> 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); _callAnalyzeSyntax = _clientHelper.BuildApiCall <AnalyzeSyntaxRequest, AnalyzeSyntaxResponse>( GrpcClient.AnalyzeSyntaxAsync, GrpcClient.AnalyzeSyntax, effectiveSettings.AnalyzeSyntaxSettings); _callAnnotateText = _clientHelper.BuildApiCall <AnnotateTextRequest, AnnotateTextResponse>( GrpcClient.AnnotateTextAsync, GrpcClient.AnnotateText, effectiveSettings.AnnotateTextSettings); }
partial void OnConstruction(LanguageService.LanguageServiceClient grpcClient, LanguageServiceSettings effectiveSettings, ClientHelper clientHelper);
partial void OnCopy(LanguageServiceSettings existing);
/// <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)); }
/// <summary> /// Synchronously creates a <see cref="LanguageServiceClient"/>, applying defaults for all unspecified settings, /// and creating a channel connecting to the given endpoint with application default credentials where /// necessary. /// </summary> /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param> /// <param name="settings">Optional <see cref="LanguageServiceSettings"/>.</param> /// <returns>The created <see cref="LanguageServiceClient"/>.</returns> public static LanguageServiceClient Create(ServiceEndpoint endpoint = null, LanguageServiceSettings settings = null) { Channel channel = s_channelPool.GetChannel(endpoint ?? DefaultEndpoint); return(Create(channel, settings)); }
// Note: we could have parameterless overloads of Create and CreateAsync, // documented to just use the default endpoint, settings and credentials. // Pros: // - Might be more reassuring on first use // - Allows method group conversions // Con: overloads! /// <summary> /// Asynchronously creates a <see cref="LanguageServiceClient"/>, applying defaults for all unspecified settings, /// and creating a channel connecting to the given endpoint with application default credentials where /// necessary. /// </summary> /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param> /// <param name="settings">Optional <see cref="LanguageServiceSettings"/>.</param> /// <returns>The task representing the created <see cref="LanguageServiceClient"/>.</returns> public static async Task <LanguageServiceClient> CreateAsync(ServiceEndpoint endpoint = null, LanguageServiceSettings settings = null) { Channel channel = await s_channelPool.GetChannelAsync(endpoint ?? DefaultEndpoint).ConfigureAwait(false); return(Create(channel, settings)); }