mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-02 02:45:32 +00:00
Create ObservableBlobClient and interface
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableBlobClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a single Blob by SHA.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/blobs/#get-a-blob
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The SHA of the blob</param>
|
||||
/// <returns>The <see cref="Blob"/> for the specified SHA.</returns>
|
||||
IObservable<Blob> Get(string owner, string name, string reference);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Blob
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/blobs/#create-a-blob
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="newBlob">The new Blob</param>
|
||||
/// <returns>The <see cref="Blob"/> that was just created.</returns>
|
||||
IObservable<Blob> Create(string owner, string name, NewBlob newBlob);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableBlobClient : IObservableBlobClient
|
||||
{
|
||||
readonly IBlobsClient _client;
|
||||
|
||||
public ObservableBlobClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Blob;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single Blob by SHA.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/blobs/#get-a-blob
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The SHA of the blob</param>
|
||||
/// <returns>The <see cref="Blob"/> for the specified SHA.</returns>
|
||||
public IObservable<Blob> Get(string owner, string name, string reference)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||
|
||||
return _client.Get(owner, name, reference).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Blob
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/blobs/#create-a-blob
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="newBlob">The new Blob</param>
|
||||
/// <returns>The <see cref="Blob"/> that was just created.</returns>
|
||||
public IObservable<Blob> Create(string owner, string name, NewBlob newBlob)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(newBlob, "newBlob");
|
||||
|
||||
return _client.Create(owner, name, newBlob).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,9 @@
|
||||
<Compile Include="..\SolutionInfo.cs">
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Clients\IObservableBlobClient.cs" />
|
||||
<Compile Include="Clients\IObservableEventsClient.cs" />
|
||||
<Compile Include="Clients\ObservableBlobClient.cs" />
|
||||
<Compile Include="Clients\ObservableEventsClient.cs" />
|
||||
<Compile Include="Clients\ObservableGitDatabaseClient.cs" />
|
||||
<Compile Include="Clients\IObservableGitDatabaseClient.cs" />
|
||||
|
||||
Reference in New Issue
Block a user