mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 03:55:55 +00:00
addressed a bunch of the Extensions changes
This commit is contained in:
@@ -7,8 +7,19 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Extensions for working with the <see cref="IApiConnection"/>
|
||||
/// </summary>
|
||||
public static class ApiExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the API resource at the specified URI.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the API resource to get.</typeparam>
|
||||
/// <param name="connection">The connection to use</param>
|
||||
/// <param name="uri">URI of the API resource to get</param>
|
||||
/// <returns>The API resource.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public static Task<T> Get<T>(this IApiConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
@@ -17,6 +28,14 @@ namespace Octokit
|
||||
return connection.Get<T>(uri, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all API resources in the list at the specified URI.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the API resource in the list.</typeparam>
|
||||
/// <param name="connection">The connection to use</param>
|
||||
/// <param name="uri">URI of the API resource to get</param>
|
||||
/// <returns><see cref="IReadOnlyList{T}"/> of the The API resources in the list.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public static Task<IReadOnlyList<T>> GetAll<T>(this IApiConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
@@ -25,6 +44,13 @@ namespace Octokit
|
||||
return connection.GetAll<T>(uri, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HTML content of the API resource at the specified URI.
|
||||
/// </summary>
|
||||
/// <param name="connection">The connection to use</param>
|
||||
/// <param name="uri">URI of the API resource to get</param>
|
||||
/// <returns>The API resource's HTML content.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public static Task<string> GetHtml(this IApiConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
@@ -32,7 +58,13 @@ namespace Octokit
|
||||
|
||||
return connection.GetHtml(uri, null);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Performs an asynchronous HTTP GET request that expects a <seealso cref="IResponse"/> containing HTML.
|
||||
/// </summary>
|
||||
/// <param name="connection">The connection to use</param>
|
||||
/// <param name="uri">URI endpoint to send request to</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
public static Task<IResponse<string>> GetHtml(this IConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
@@ -41,6 +73,14 @@ namespace Octokit
|
||||
return connection.GetHtml(uri, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the API resource at the specified URI.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the API resource to get.</typeparam>
|
||||
/// <param name="connection">The connection to use</param>
|
||||
/// <param name="uri">URI of the API resource to get</param>
|
||||
/// <returns>The API resource.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public static Task<IResponse<T>> GetResponse<T>(this IConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
@@ -49,6 +89,15 @@ namespace Octokit
|
||||
return connection.Get<T>(uri, null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the API resource at the specified URI.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the API resource to get.</typeparam>
|
||||
/// <param name="connection">The connection to use</param>
|
||||
/// <param name="uri">URI of the API resource to get</param>
|
||||
/// <param name="cancellationToken">A token used to cancel the GetResponse request</param>
|
||||
/// <returns>The API resource.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public static Task<IResponse<T>> GetResponse<T>(this IConnection connection, Uri uri, CancellationToken cancellationToken)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
|
||||
@@ -3,6 +3,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents operations to simplify triggering the authorization flow
|
||||
/// </summary>
|
||||
public static class AuthorizationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,9 @@ namespace Octokit
|
||||
{
|
||||
public static class HttpClientExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// OBSOLETE
|
||||
/// </summary>
|
||||
[Obsolete("This will be removed in a future release")]
|
||||
public static Task<IResponse<T>> Send<T>(this IHttpClient httpClient, IRequest request)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,12 @@ namespace Octokit
|
||||
/// </remarks>
|
||||
public interface IApiPagination
|
||||
{
|
||||
/// <summary>
|
||||
/// Paginate a request to asynchronous fetch the results until no more are returned
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the API resource to get.</typeparam>
|
||||
/// <param name="getFirstPage">A function which generates the first request</param>
|
||||
/// <param name="uri">The original URI (used only for raising an exception)</param>
|
||||
Task<IReadOnlyList<T>> GetAllPages<T>(Func<Task<IReadOnlyPagedCollection<T>>> getFirstPage, Uri uri);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
// TODO: this is only related to SSH keys, we should rename this
|
||||
|
||||
/// <summary>
|
||||
/// Extensions for working with SSH keys
|
||||
/// </summary>
|
||||
public static class ModelExtensions
|
||||
{
|
||||
#if NETFX_CORE
|
||||
@@ -10,6 +15,10 @@ namespace Octokit
|
||||
static readonly Regex sshKeyRegex = new Regex(@"ssh-[rd]s[as] (?<data>\S+) ?(?<name>.*)$", RegexOptions.Compiled);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Extract SSH key information from the API response
|
||||
/// </summary>
|
||||
/// <param name="sshKey">Key details received from API</param>
|
||||
public static SshKeyInfo GetKeyDataAndName(this SshKey sshKey)
|
||||
{
|
||||
Ensure.ArgumentNotNull(sshKey, "sshKey");
|
||||
@@ -20,6 +29,11 @@ namespace Octokit
|
||||
return (match.Success ? new SshKeyInfo(match.Groups["data"].Value, match.Groups["name"].Value) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare two SSH keys to see if they are equal
|
||||
/// </summary>
|
||||
/// <param name="key">Reference SSH key</param>
|
||||
/// <param name="otherKey">Key to compare</param>
|
||||
public static bool HasSameDataAs(this SshKey key, SshKey otherKey)
|
||||
{
|
||||
Ensure.ArgumentNotNull(key, "key");
|
||||
|
||||
@@ -2,10 +2,21 @@
|
||||
|
||||
namespace Octokit.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicate to the serializer that this property or value
|
||||
/// has a different representation when being serialized to JSON
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public sealed class ParameterAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// The key to use in place of the property's name
|
||||
/// </summary>
|
||||
public string Key { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name to use in place of the enum's value
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
namespace Octokit.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicate to the serializer that this property or field
|
||||
/// should be included, even when currently set to `null`
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public sealed class SerializeNullAttribute : Attribute
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user