mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-05-22 14:33:12 +00:00
72e30a7f90
* add reactions to issue response payload * add reactions to commit comment payload * add reactions to review comment payload * create tests for issue client * tests for commitcomment client * tests for pull request review comment * change observable tests * simplify strings * remove unnecessary clients * change integration tests to retrieve all reaction types * create integration test for issue comment client * fix merge conflicts * fix merge conflicts * gets tests passing again * fix some reaction integration tests * Fixup unit tests wth preview accepts header Also applied preview header to a couple of repositoryId based calls that were added by another PR * Fixup unit tests wth preview accepts header Also applied preview header to a couple of repositoryId based calls that were added by another PR * Rework reaction payload tests for IssueComments to handle Get, GetAllForIssue and GetAllForRepository calls * [WIP] reaction payload tests * Rework reaction payload tests for IssueComments to handle Get, GetAllForIssue and GetAllForRepository calls * Rework reaction payload tests for Issues client * Rework reaction payload tests for PullRequestReviews client * Rework reaction payload tests for CommitComments client * Revert "[WIP] reaction payload tests" This reverts commit a6179b0f21a3ddfe36bfd3ae5eafae0e69b52252.
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class Readme
{
readonly Lazy<Task<string>> htmlContent;
public Readme() { }
internal Readme(ReadmeResponse response, IApiConnection client)
{
Ensure.ArgumentNotNull(response, "response");
Ensure.ArgumentNotNull(client, "client");
Name = response.Name;
Url = new Uri(response.Url);
HtmlUrl = new Uri(response.HtmlUrl);
if (response.Encoding.Equals("base64", StringComparison.OrdinalIgnoreCase))
{
var contentAsBytes = Convert.FromBase64String(response.Content);
Content = Encoding.UTF8.GetString(contentAsBytes, 0, contentAsBytes.Length);
}
htmlContent = new Lazy<Task<string>>(async () => await client.GetHtml(Url).ConfigureAwait(false));
}
public Readme(Lazy<Task<string>> htmlContent, string content, string name, Uri htmlUrl, Uri url)
{
this.htmlContent = htmlContent;
Content = content;
Name = name;
HtmlUrl = htmlUrl;
Url = url;
}
public string Content { get; private set; }
public string Name { get; private set; }
public Uri HtmlUrl { get; private set; }
public Uri Url { get; private set; }
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
public Task<string> GetHtmlContent()
{
return htmlContent.Value;
}
internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture, "Name: {0} ", Name);
}
}
}
}