Implement IObservableAssigneesClient

This commit is contained in:
Keith Dahlby
2013-10-30 22:14:05 -05:00
parent f41a081792
commit 3fb3e8966c
3 changed files with 56 additions and 6 deletions
@@ -1,8 +1,9 @@
using System.Threading.Tasks;
using System;
using System.Collections.Generic;
namespace Octokit
namespace Octokit.Reactive
{
public interface IAssigneesClient
public interface IObservableAssigneesClient
{
/// <summary>
/// Gets all the available assignees (owner + collaborators) to which issues may be assigned.
@@ -10,7 +11,7 @@ namespace Octokit
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <returns></returns>
Task<IReadOnlyList<User>> GetForRepository(string owner, string name);
IObservable<IReadOnlyList<User>> GetForRepository(string owner, string name);
/// <summary>
/// Checks to see if a user is an assignee for a repository.
@@ -19,6 +20,6 @@ namespace Octokit
/// <param name="name">The name of the repository</param>
/// <param name="assignee">Username of the prospective assignee</param>
/// <returns></returns>
Task<bool> CheckAssignee(string owner, string name, string assignee);
IObservable<bool> CheckAssignee(string owner, string name, string assignee);
}
}
@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Reactive.Threading.Tasks;
namespace Octokit.Reactive
{
public class ObservableAssigneesClient : IObservableAssigneesClient
{
readonly IAssigneesClient _client;
public ObservableAssigneesClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
_client = client.Issue.Assignee;
}
/// <summary>
/// Gets all the available assignees (owner + collaborators) to which issues may be assigned.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <returns></returns>
public IObservable<IReadOnlyList<User>> GetForRepository(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return _client.GetForRepository(owner, name).ToObservable();
}
/// <summary>
/// Checks to see if a user is an assignee for a repository.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="assignee">Username of the prospective assignee</param>
/// <returns></returns>
public IObservable<bool> CheckAssignee(string owner, string name, string assignee)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(assignee, "assignee");
return _client.CheckAssignee(owner, name, assignee).ToObservable();
}
}
}
+2 -1
View File
@@ -71,6 +71,7 @@
<Compile Include="..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
<Compile Include="Clients\ObservableAssigneesClient.cs" />
<Compile Include="Clients\IObservableCommitStatusClient.cs" />
<Compile Include="Clients\ObservableCommitStatusClient.cs" />
<Compile Include="Clients\ObservableNotificationsClient.cs" />
@@ -81,7 +82,7 @@
<Compile Include="Clients\ObservableRepositoriesClient.cs" />
<Compile Include="Clients\ObservableSshKeysClient.cs" />
<Compile Include="Clients\ObservableUsersClient.cs" />
<Compile Include="Clients\IAssigneesClient.cs" />
<Compile Include="Clients\IObservableAssigneesClient.cs" />
<Compile Include="Clients\IObservableNotificationsClient.cs" />
<Compile Include="Helpers\AuthorizationExtensions.cs" />
<Compile Include="Helpers\ConnectionExtensions.cs" />