LEFT | RIGHT |
1 /* | 1 /* |
2 Copyright 2013 Google Inc | 2 Copyright 2013 Google Inc |
3 | 3 |
4 Licensed under the Apache License, Version 2.0 (the "License"); | 4 Licensed under the Apache License, Version 2.0 (the "License"); |
5 you may not use this file except in compliance with the License. | 5 you may not use this file except in compliance with the License. |
6 You may obtain a copy of the License at | 6 You may obtain a copy of the License at |
7 | 7 |
8 http://www.apache.org/licenses/LICENSE-2.0 | 8 http://www.apache.org/licenses/LICENSE-2.0 |
9 | 9 |
10 Unless required by applicable law or agreed to in writing, software | 10 Unless required by applicable law or agreed to in writing, software |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 { | 62 { |
63 None = 0, | 63 None = 0, |
64 Exception = 1, | 64 Exception = 1, |
65 UnsuccessfulResponse503 = 2 | 65 UnsuccessfulResponse503 = 2 |
66 } | 66 } |
67 | 67 |
68 /// <summary> An initializer class for the client service. </summary> | 68 /// <summary> An initializer class for the client service. </summary> |
69 public class Initializer | 69 public class Initializer |
70 { | 70 { |
71 /// <summary>· | 71 /// <summary>· |
72 /// A factory for creating <see cref="System.Net.Http.HttpClient"/>
instance. If this property is not set | 72 /// Gets or sets the factory for creating <see cref="System.Net.Http
.HttpClient"/> instance. If this· |
73 /// the service uses a new <see cref="Google.Apis.Http.HttpClientFac
tory"/> instance. | 73 /// property is not set the service uses a new <see cref="Google.Api
s.Http.HttpClientFactory"/> instance. |
74 /// </summary> | 74 /// </summary> |
75 public IHttpClientFactory HttpClientFactory { get; set; } | 75 public IHttpClientFactory HttpClientFactory { get; set; } |
76 | 76 |
77 /// <summary> | 77 /// <summary> |
78 /// An Http client initializer which is able to customize properties
on· | 78 /// Gets or sets an Http client initializer which is able to customi
ze properties on· |
79 /// <see cref="Google.Apis.Http.ConfigurableHttpClient"/> and· | 79 /// <see cref="Google.Apis.Http.ConfigurableHttpClient"/> and· |
80 /// <see cref="Google.Apis.Http.ConfigurableMessageHandler"/>. | 80 /// <see cref="Google.Apis.Http.ConfigurableMessageHandler"/>. |
81 /// </summary> | 81 /// </summary> |
82 public IConfigurableHttpClientInitializer HttpClientInitializer { ge
t; set; } | 82 public IConfigurableHttpClientInitializer HttpClientInitializer { ge
t; set; } |
83 | 83 |
84 /// <summary> | 84 /// <summary> |
85 /// Get or sets the exponential back-off policy used by the service.
Default value is· | 85 /// Get or sets the exponential back-off policy used by the service.
Default value is· |
86 /// <c>UnsuccessfulResponse503</c>, which means that exponential bac
k-off is used on 503 abnormal Http | 86 /// <c>UnsuccessfulResponse503</c>, which means that exponential bac
k-off is used on 503 abnormal HTTP |
87 /// response. | 87 /// response. |
88 /// If the value is set to <c>None</c>, no exponential back-off poli
cy is used, and it's up to user to | 88 /// If the value is set to <c>None</c>, no exponential back-off poli
cy is used, and it's up to user to |
89 /// configure the <seealso cref="Google.Apis.Http.ConfigurableMessag
eHandler"/> in an | 89 /// configure the <seealso cref="Google.Apis.Http.ConfigurableMessag
eHandler"/> in an |
90 /// <seealso cref="Google.Apis.Http.IConfigurableHttpClientInitializ
er"/> to set a specific back-off | 90 /// <seealso cref="Google.Apis.Http.IConfigurableHttpClientInitializ
er"/> to set a specific back-off |
91 /// implementation (using <seealso cref="Google.Api.Http.BackOffHand
ler"/>). | 91 /// implementation (using <seealso cref="Google.Api.Http.BackOffHand
ler"/>). |
92 /// </summary> | 92 /// </summary> |
93 public ExponentialBackOffPolicy DefaultExponentialBackOffPolicy { ge
t; set; } | 93 public ExponentialBackOffPolicy DefaultExponentialBackOffPolicy { ge
t; set; } |
94 | 94 |
95 /// <summary> Gets and Sets whether this service supports GZip. Defa
ult value is <c>true</c>. </summary> | 95 /// <summary> Gets or sets whether this service supports GZip. Defau
lt value is <c>true</c>. </summary> |
96 public bool GZipEnabled { get; set; } | 96 public bool GZipEnabled { get; set; } |
97 | 97 |
98 /// <summary> | 98 /// <summary> |
99 /// Gets and Sets the Serializer. Default value is <see cref="Google
.Apis.Json.NewtonsoftJsonSerializer"/>. | 99 /// Gets and Sets the Serializer. Default value is <see cref="Google
.Apis.Json.NewtonsoftJsonSerializer"/>. |
100 /// </summary> | 100 /// </summary> |
101 public ISerializer Serializer { get; set; } | 101 public ISerializer Serializer { get; set; } |
102 | 102 |
103 /// <summary> Gets and Sets the API Key. Default value is <c>null</c
>. </summary> | 103 /// <summary> Gets or sets the API Key. Default value is <c>null</c>
. </summary> |
104 public string ApiKey { get; set; } | 104 public string ApiKey { get; set; } |
105 | 105 |
106 /// <summary>· | 106 /// <summary>· |
107 /// Gets and Sets the Authenticator. Default value is· | 107 /// Gets or sets the Authenticator. Default value is· |
108 /// <see cref="Google.Apis.Authentication.NullAuthenticator.Instance
"/>. | 108 /// <see cref="Google.Apis.Authentication.NullAuthenticator.Instance
"/>. |
109 /// </summary> | 109 /// </summary> |
110 public IAuthenticator Authenticator { get; set; } | 110 public IAuthenticator Authenticator { get; set; } |
111 | 111 |
112 /// <summary>· | 112 /// <summary>· |
113 /// Gets and sets Application name to be used in the User-Agent head
er. Default value is <c>null</c>.· | 113 /// Gets or sets Application name to be used in the User-Agent heade
r. Default value is <c>null</c>.· |
114 /// </summary> | 114 /// </summary> |
115 public string ApplicationName { get; set; } | 115 public string ApplicationName { get; set; } |
116 | 116 |
117 /// <summary> Constructs a new initializer with default values. </su
mmary> | 117 /// <summary> Constructs a new initializer with default values. </su
mmary> |
118 public Initializer() | 118 public Initializer() |
119 { | 119 { |
120 GZipEnabled = true; | 120 GZipEnabled = true; |
121 Serializer = new NewtonsoftJsonSerializer(); | 121 Serializer = new NewtonsoftJsonSerializer(); |
122 Authenticator = NullAuthenticator.Instance; | 122 Authenticator = NullAuthenticator.Instance; |
123 DefaultExponentialBackOffPolicy = ExponentialBackOffPolicy.Unsuc
cessfulResponse503; | 123 DefaultExponentialBackOffPolicy = ExponentialBackOffPolicy.Unsuc
cessfulResponse503; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 374 |
375 #endregion | 375 #endregion |
376 | 376 |
377 #region Abstract Memebrs | 377 #region Abstract Memebrs |
378 | 378 |
379 public abstract string Name { get; } | 379 public abstract string Name { get; } |
380 public abstract string BaseUri { get; } | 380 public abstract string BaseUri { get; } |
381 public abstract string BasePath { get; } | 381 public abstract string BasePath { get; } |
382 | 382 |
383 public abstract IList<string> Features { get; } | 383 public abstract IList<string> Features { get; } |
384 public abstract IDictionary<string, IParameter> ServiceParameters { get;
} | |
385 | 384 |
386 #endregion | 385 #endregion |
387 | 386 |
388 #endregion | 387 #endregion |
389 | 388 |
390 /// <summary> Creates a GZip stream by the given serialized object. </su
mmary> | 389 /// <summary> Creates a GZip stream by the given serialized object. </su
mmary> |
391 private static Stream CreateGZipStream(string serializedObject) | 390 private static Stream CreateGZipStream(string serializedObject) |
392 { | 391 { |
393 byte[] bytes = System.Text.Encoding.UTF8.GetBytes(serializedObject); | 392 byte[] bytes = System.Text.Encoding.UTF8.GetBytes(serializedObject); |
394 using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) | 393 using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) |
(...skipping 13 matching lines...) Expand all Loading... |
408 | 407 |
409 public virtual void Dispose() | 408 public virtual void Dispose() |
410 { | 409 { |
411 if (HttpClient != null) | 410 if (HttpClient != null) |
412 { | 411 { |
413 HttpClient.Dispose(); | 412 HttpClient.Dispose(); |
414 } | 413 } |
415 } | 414 } |
416 } | 415 } |
417 } | 416 } |
LEFT | RIGHT |