mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 03:30:34 +00:00
aaaand format the code
This commit is contained in:
@@ -446,7 +446,7 @@ namespace Octokit
|
||||
case HttpStatusCode.Accepted:
|
||||
continue;
|
||||
case HttpStatusCode.NoContent:
|
||||
return new ReadOnlyCollection<T>(new T[] {});
|
||||
return new ReadOnlyCollection<T>(new T[] { });
|
||||
case HttpStatusCode.OK:
|
||||
return response.Body;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,5 @@ namespace Octokit
|
||||
new String(this.Etag.ToCharArray()),
|
||||
this.RateLimit.Clone());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +263,6 @@ namespace Octokit
|
||||
Ensure.ArgumentNotNullOrEmptyString(twoFactorAuthenticationCode, "twoFactorAuthenticationCode");
|
||||
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None, twoFactorAuthenticationCode);
|
||||
|
||||
}
|
||||
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, TimeSpan timeout)
|
||||
@@ -525,7 +524,7 @@ namespace Octokit
|
||||
return new ApiResponse<string>(response, response.Body as string);
|
||||
}
|
||||
|
||||
async Task<IApiResponse<T>> Run<T>(IRequest request, CancellationToken cancellationToken)
|
||||
async Task<IApiResponse<T>> Run<T>(IRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
_jsonPipeline.SerializeRequest(request);
|
||||
var response = await RunRequest(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Octokit
|
||||
|
||||
public AuthenticationType AuthenticationType
|
||||
{
|
||||
get;
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,36 +201,37 @@ namespace Octokit.Internal
|
||||
|| response.StatusCode == HttpStatusCode.SeeOther
|
||||
|| response.StatusCode == HttpStatusCode.TemporaryRedirect
|
||||
|| (int)response.StatusCode == 308)
|
||||
{
|
||||
var newRequest = CopyRequest(response.RequestMessage);
|
||||
{
|
||||
var newRequest = CopyRequest(response.RequestMessage);
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.SeeOther)
|
||||
if (response.StatusCode == HttpStatusCode.SeeOther)
|
||||
{
|
||||
newRequest.Content = null;
|
||||
newRequest.Method = HttpMethod.Get;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (request.Content != null && request.Content.Headers.ContentLength != 0)
|
||||
{
|
||||
var stream = await request.Content.ReadAsStreamAsync();
|
||||
if (stream.CanSeek)
|
||||
{
|
||||
newRequest.Content = null;
|
||||
newRequest.Method = HttpMethod.Get;
|
||||
stream.Position = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (request.Content != null && request.Content.Headers.ContentLength != 0) {
|
||||
var stream = await request.Content.ReadAsStreamAsync();
|
||||
if (stream.CanSeek)
|
||||
{
|
||||
stream.Position = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Cannot redirect a request with an unbuffered body");
|
||||
}
|
||||
newRequest.Content = new StreamContent(stream);
|
||||
}
|
||||
throw new Exception("Cannot redirect a request with an unbuffered body");
|
||||
}
|
||||
newRequest.RequestUri = response.Headers.Location;
|
||||
if (String.Compare(newRequest.RequestUri.Host, request.RequestUri.Host, StringComparison.OrdinalIgnoreCase) != 0)
|
||||
{
|
||||
newRequest.Headers.Authorization = null;
|
||||
}
|
||||
response = await this.SendAsync(newRequest, cancellationToken);
|
||||
newRequest.Content = new StreamContent(stream);
|
||||
}
|
||||
}
|
||||
newRequest.RequestUri = response.Headers.Location;
|
||||
if (String.Compare(newRequest.RequestUri.Host, request.RequestUri.Host, StringComparison.OrdinalIgnoreCase) != 0)
|
||||
{
|
||||
newRequest.Headers.Authorization = null;
|
||||
}
|
||||
response = await this.SendAsync(newRequest, cancellationToken);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Octokit
|
||||
/// <returns><see cref="IReadOnlyList{T}"/> of the The API resources in the list.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
Task<IReadOnlyList<T>> GetAll<T>(Uri uri);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets all API resources in the list at the specified URI.
|
||||
/// </summary>
|
||||
@@ -109,7 +109,7 @@ namespace Octokit
|
||||
/// <param name="accepts">Accept header to use for the API request</param>
|
||||
/// <returns>The created API resource.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
Task<T> Post<T>(Uri uri, object data, string accepts);
|
||||
Task<T> Post<T>(Uri uri, object data, string accepts);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new API resource in the list at the specified URI.
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Octokit
|
||||
/// Retrieve the credentials from the underlying store
|
||||
/// </summary>
|
||||
/// <returns>A continuation containing credentials</returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification="Nope")]
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Nope")]
|
||||
Task<Credentials> GetCredentials();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Octokit
|
||||
/// Raw response body. Typically a string, but when requesting images, it will be a byte array.
|
||||
/// </summary>
|
||||
object Body { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Information about the API.
|
||||
/// </summary>
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Octokit.Internal
|
||||
{
|
||||
request.Headers["Accept"] = v3ApiVersion;
|
||||
}
|
||||
|
||||
|
||||
if (request.Method == HttpMethod.Get || request.Body == null) return;
|
||||
if (request.Body is string || request.Body is Stream || request.Body is HttpContent) return;
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ namespace Octokit
|
||||
: ISerializable
|
||||
#endif
|
||||
{
|
||||
public RateLimit() {}
|
||||
public RateLimit() { }
|
||||
|
||||
public RateLimit(IDictionary<string, string> responseHeaders)
|
||||
{
|
||||
Ensure.ArgumentNotNull(responseHeaders, "responseHeaders");
|
||||
|
||||
Limit = (int) GetHeaderValueAsInt32Safe(responseHeaders, "X-RateLimit-Limit");
|
||||
Remaining = (int) GetHeaderValueAsInt32Safe(responseHeaders, "X-RateLimit-Remaining");
|
||||
Limit = (int)GetHeaderValueAsInt32Safe(responseHeaders, "X-RateLimit-Limit");
|
||||
Remaining = (int)GetHeaderValueAsInt32Safe(responseHeaders, "X-RateLimit-Remaining");
|
||||
ResetAsUtcEpochSeconds = GetHeaderValueAsInt32Safe(responseHeaders, "X-RateLimit-Reset");
|
||||
}
|
||||
|
||||
@@ -113,6 +113,5 @@ namespace Octokit
|
||||
ResetAsUtcEpochSeconds = this.ResetAsUtcEpochSeconds
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Octokit.Internal
|
||||
foreach (var property in propertiesAndFields.Where(p => p.SerializeNull))
|
||||
{
|
||||
var key = type.FullName + "-" + property.JsonFieldName;
|
||||
|
||||
|
||||
_membersWhichShouldPublishNull.Add(key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user