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.
Inherited Members
Namespace: Google.Apis.Services
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
Type | Name | Description |
---|---|---|
Base |
initializer |
Fields
DefaultMaxUrlLength
The default maximum allowed length of a URL string for GET requests.
Declaration
public const uint DefaultMaxUrlLength = 2048
Field Value
Type | Description |
---|---|
uint |
Properties
ApiKey
Gets the API-Key (DeveloperKey) which this service uses for all requests.
Declaration
public string ApiKey { get; }
Property Value
Type | Description |
---|---|
string |
ApplicationName
Gets the application name to be used in the User-Agent header.
Declaration
public string ApplicationName { get; }
Property Value
Type | Description |
---|---|
string |
BasePath
Gets the BasePath of the service.
Declaration
public abstract string BasePath { get; }
Property Value
Type | Description |
---|---|
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 |
---|---|
string |
BaseUriOverride
The BaseUri provided in the initializer, which may be null.
Declaration
protected string BaseUriOverride { get; }
Property Value
Type | Description |
---|---|
string |
BatchPath
The path used for batch operations.
Declaration
public virtual string BatchPath { get; }
Property Value
Type | Description |
---|---|
string |
BatchUri
The URI used for batch operations.
Declaration
public virtual string BatchUri { get; }
Property Value
Type | Description |
---|---|
string |
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
Type | Description |
---|---|
bool |
HttpClient
Gets the HTTP client which is used to create requests.
Declaration
public ConfigurableHttpClient HttpClient { get; }
Property Value
Type | Description |
---|---|
Configurable |
HttpClientInitializer
Gets a HTTP client initializer which is able to custom properties on
Google.
Declaration
public IConfigurableHttpClientInitializer HttpClientInitializer { get; }
Property Value
Type | Description |
---|---|
IConfigurable |
HttpClientTimeout
The timeout to set on Http
Declaration
public TimeSpan? HttpClientTimeout { get; }
Property Value
Type | Description |
---|---|
Time |
Name
Gets the service name.
Declaration
public abstract string Name { get; }
Property Value
Type | Description |
---|---|
string |
Serializer
Gets the Serializer used by this service.
Declaration
public ISerializer Serializer { get; }
Property Value
Type | Description |
---|---|
ISerializer |
UniverseDomain
The universe domain to connect to, or null to use the default universe domain,
which may be configured via the Universe
Declaration
public string UniverseDomain { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
Universe
Methods
CreateBackOffHandler()
Creates the back-off handler with Google.
Declaration
protected virtual BackOffHandler CreateBackOffHandler()
Returns
Type | Description |
---|---|
Back |
DeserializeError(HttpResponseMessage)
Deserializes an error response into a Google.
Declaration
public virtual Task<RequestError> DeserializeError(HttpResponseMessage response)
Parameters
Type | Name | Description |
---|---|---|
Http |
response |
Returns
Type | Description |
---|---|
Task<Request |
Exceptions
Type | Condition |
---|---|
Google |
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
Type | Name | Description |
---|---|---|
Http |
response |
Returns
Type | Description |
---|---|
Task<T> |
Type Parameters
Name | Description |
---|---|
T |
Dispose()
Declaration
public virtual void Dispose()
GetEffectiveUri(string, string)
Gets the effective URI taking into account the Universe
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
Type | Description |
---|---|
string |
|
SerializeObject(object)
Serializes an object into a string representation.
Declaration
public virtual string SerializeObject(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj |
Returns
Type | Description |
---|---|
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 |
---|---|---|
Http |
request | |
object | body |