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
Google.Apis.Http.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 Google.Apis.Http.ConfigurableMessageHandler's unsuccessful
response handler list.
Inheritance
BaseClientService
Assembly: Google.Apis.dll
Syntax
public abstract class BaseClientService : IClientService, IDisposable
Constructors
BaseClientService(Initializer)
Constructs a new base client with the specified initializer.
Declaration
protected BaseClientService(BaseClientService.Initializer initializer)
Parameters
Fields
DefaultMaxUrlLength
The default maximum allowed length of a URL string for GET requests.
Declaration
public const uint DefaultMaxUrlLength = 2048
Field Value
Properties
ApiKey
Gets the API-Key (DeveloperKey) which this service uses for all requests.
Declaration
public string ApiKey { get; }
Property Value
ApplicationName
Gets the application name to be used in the User-Agent header.
Declaration
public string ApplicationName { get; }
Property Value
BasePath
Gets the BasePath of the service.
Declaration
public abstract string BasePath { get; }
Property Value
BaseUri
Gets the BaseUri of the service. All request paths should be relative to this URI.
Declaration
public abstract string BaseUri { get; }
Property Value
BaseUriOverride
The BaseUri provided in the initializer, which may be null.
Declaration
protected string BaseUriOverride { get; }
Property Value
BatchPath
The path used for batch operations.
Declaration
public virtual string BatchPath { get; }
Property Value
BatchUri
The URI used for batch operations.
Declaration
public virtual string BatchUri { get; }
Property Value
Features
Gets the supported features by this service.
Declaration
public abstract IList<string> Features { get; }
Property Value
GZipEnabled
Gets or sets whether this service supports GZip.
Declaration
public bool GZipEnabled { get; }
Property Value
HttpClient
Gets the HTTP client which is used to create requests.
Declaration
public ConfigurableHttpClient HttpClient { get; }
Property Value
Type |
Description |
ConfigurableHttpClient |
|
HttpClientInitializer
Gets a HTTP client initializer which is able to custom properties on
Google.Apis.Http.ConfigurableHttpClient and
Google.Apis.Http.ConfigurableMessageHandler.
Declaration
public IConfigurableHttpClientInitializer HttpClientInitializer { get; }
Property Value
Type |
Description |
IConfigurableHttpClientInitializer |
|
HttpClientTimeout
The timeout to set on HttpClient instances used by the service.
May be null, in which case the default timeout values on HttpClient instances
used by this service will be left unchanged.
Declaration
public TimeSpan? HttpClientTimeout { get; }
Property Value
Name
Declaration
public abstract string Name { get; }
Property Value
Serializer
Gets the Serializer used by this service.
Declaration
public ISerializer Serializer { get; }
Property Value
Type |
Description |
ISerializer |
|
UniverseDomain
Declaration
public string UniverseDomain { get; set; }
Property Value
Remarks
Methods
CreateBackOffHandler()
Creates the back-off handler with Google.Apis.Util.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
Google.Apis.Util.IBackOff).
Declaration
protected virtual BackOffHandler CreateBackOffHandler()
Returns
Type |
Description |
BackOffHandler |
|
DeserializeError(HttpResponseMessage)
Deserializes an error response into a Google.Apis.Requests.RequestError object.
Declaration
public virtual Task<RequestError> DeserializeError(HttpResponseMessage response)
Parameters
Returns
Type |
Description |
Task<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 Task<T> DeserializeResponse<T>(HttpResponseMessage response)
Parameters
Returns
Type Parameters
Dispose()
Declaration
public virtual void Dispose()
GetEffectiveUri(string, string)
Declaration
protected string GetEffectiveUri(string explicitUri, string defaultUri)
Parameters
Type |
Name |
Description |
string |
explicitUri |
An explicit URI. May be null.
|
string |
defaultUri |
A default URI. May be null.
|
Returns
SerializeObject(object)
Serializes an object into a string representation.
Declaration
public virtual string SerializeObject(object obj)
Parameters
Type |
Name |
Description |
object |
obj |
|
Returns
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
Implements