Skip to content

Commit

Permalink
cleanup these dictionary responses to be have consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed Jan 4, 2015
1 parent 2395eec commit ec2f6dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Octokit.Tests/Clients/RepositoriesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public void GetsCorrectUrl()
client.GetAllLanguages("owner", "name");

connection.Received()
.Get<IDictionary<string, long>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/languages"), null);
.Get<Dictionary<string, long>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/languages"), null);
}

[Fact]
Expand Down
15 changes: 7 additions & 8 deletions Octokit/Clients/RepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,18 +386,17 @@ public Task<IReadOnlyList<RepositoryContributor>> GetAllContributors(string owne
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <returns>All languages used in the repository and the number of bytes of each language.</returns>
public Task<IReadOnlyList<RepositoryLanguage>> GetAllLanguages(string owner, string name)
public async Task<IReadOnlyList<RepositoryLanguage>> GetAllLanguages(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");

return ApiConnection
.Get<IDictionary<string, long>>(ApiUrls.RepositoryLanguages(owner, name))
.ContinueWith<IReadOnlyList<RepositoryLanguage>>(t =>
new ReadOnlyCollection<RepositoryLanguage>(
t.Result.Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList()
),
TaskContinuationOptions.OnlyOnRanToCompletion);
var data = await ApiConnection
.Get<Dictionary<string, long>>(ApiUrls.RepositoryLanguages(owner, name))
.ConfigureAwait(false);

return new ReadOnlyCollection<RepositoryLanguage>(
data.Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList());
}

/// <summary>
Expand Down

0 comments on commit ec2f6dd

Please sign in to comment.