Show / Hide Table of Contents

Class BaseClientService

A base class for a client service which provides common mechanism for all services, like serialization and GZip support. It should be safe to use a single service instance to make server requests concurrently from multiple threads. This class adds a special Google.Apis.Http.IHttpExecuteInterceptor to the ConfigurableMessageHandler execute interceptor list, which uses the given Authenticator. It calls to its applying authentication method, and injects the "Authorization" header in the request. If the given Authenticator implements Google.Apis.Http.IHttpUnsuccessfulResponseHandler, this class adds the Authenticator to the ConfigurableMessageHandler's unsuccessful response handler list.

Inheritance
System.Object
BaseClientService
Implements
IClientService
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Google.Apis.Services
Assembly: Google.Apis.dll
Syntax
public abstract class BaseClientService : IClientService, IDisposable

Constructors

BaseClientService(BaseClientService.Initializer)

Constructs a new base client with the specified initializer.

Declaration
protected BaseClientService(BaseClientService.Initializer initializer)
Parameters
Type Name Description
BaseClientService.Initializer initializer

Fields

DefaultMaxUrlLength

The default maximum allowed length of a URL string for GET requests.

Declaration
public const uint DefaultMaxUrlLength = 2048U
Field Value
Type Description
System.UInt32

Properties

ApiKey

Gets the API-Key (DeveloperKey) which this service uses for all requests.

Declaration
public string ApiKey { get; }
Property Value
Type Description
System.String

ApplicationName

Gets the application name to be used in the User-Agent header.

Declaration
public string ApplicationName { get; }
Property Value
Type Description
System.String

BasePath

Gets the BasePath of the service.

Declaration
public abstract string BasePath { get; }
Property Value
Type Description
System.String

BaseUri

Gets the BaseUri of the service. All request paths should be relative to this URI.

Declaration
public abstract string BaseUri { get; }
Property Value
Type Description
System.String

BaseUriOverride

The BaseUri provided in the initializer, which may be null.

Declaration
protected string BaseUriOverride { get; }
Property Value
Type Description
System.String

BatchPath

The path used for batch operations.

Declaration
public virtual string BatchPath { get; }
Property Value
Type Description
System.String

BatchUri

The URI used for batch operations.

Declaration
public virtual string BatchUri { get; }
Property Value
Type Description
System.String

Features

Gets the supported features by this service.

Declaration
public abstract IList<string> Features { get; }
Property Value
Type Description
System.Collections.Generic.IList<System.String>

GZipEnabled

Gets or sets whether this service supports GZip.

Declaration
public bool GZipEnabled { get; }
Property Value
Type Description
System.Boolean

HttpClient

Gets the HTTP client which is used to create requests.

Declaration
public ConfigurableHttpClient HttpClient { get; }
Property Value
Type Description
Google.Apis.Http.ConfigurableHttpClient

HttpClientInitializer

Gets a HTTP client initializer which is able to custom properties on Google.Apis.Http.ConfigurableHttpClient and ConfigurableMessageHandler.

Declaration
public IConfigurableHttpClientInitializer HttpClientInitializer { get; }
Property Value
Type Description
Google.Apis.Http.IConfigurableHttpClientInitializer

Name

Gets the service name.

Declaration
public abstract string Name { get; }
Property Value
Type Description
System.String

Serializer

Gets the Serializer used by this service.

Declaration
public ISerializer Serializer { get; }
Property Value
Type Description
Google.Apis.ISerializer

Methods

CreateBackOffHandler()

Creates the back-off handler with ExponentialBackOff. Overrides this method to change the default behavior of back-off handler (e.g. you can change the maximum waited request's time span, or create a back-off handler with you own implementation of IBackOff).

Declaration
protected virtual BackOffHandler CreateBackOffHandler()
Returns
Type Description
Google.Apis.Http.BackOffHandler

DeserializeError(HttpResponseMessage)

Deserializes an error response into a Google.Apis.Requests.RequestError object.

Declaration
public virtual Task<RequestError> DeserializeError(HttpResponseMessage response)
Parameters
Type Name Description
System.Net.Http.HttpResponseMessage response
Returns
Type Description
System.Threading.Tasks.Task<Google.Apis.Requests.RequestError>
Exceptions
Type Condition
GoogleApiException

If no error is found in the response.

DeserializeResponse<T>(HttpResponseMessage)

Deserializes a response into the specified object.

Declaration
public virtual async Task<T> DeserializeResponse<T>(HttpResponseMessage response)
Parameters
Type Name Description
System.Net.Http.HttpResponseMessage response
Returns
Type Description
System.Threading.Tasks.Task<T>
Type Parameters
Name Description
T

Dispose()

Declaration
public virtual void Dispose()

SerializeObject(Object)

Serializes an object into a string representation.

Declaration
public virtual string SerializeObject(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.String

SetRequestSerailizedContent(HttpRequestMessage, Object)

Sets the content of the request by the given body and the this service's configuration. First the body object is serialized by the Serializer and then, if GZip is enabled, the content will be wrapped in a GZip stream, otherwise a regular string stream will be used.

Declaration
public void SetRequestSerailizedContent(HttpRequestMessage request, object body)
Parameters
Type Name Description
System.Net.Http.HttpRequestMessage request
System.Object body

Implements

IClientService
System.IDisposable
In This Article
Back to top