Files
octokit.net/Octokit/Models/Response
..
2016-05-20 19:14:36 +05:30
2015-11-04 13:38:51 -08:00
2015-12-16 21:23:36 +02:00
2016-01-21 07:31:32 +02:00
2016-01-21 07:31:32 +02:00
2016-03-29 17:42:33 +07:00
2015-12-16 21:23:36 +02:00
2015-12-16 21:23:36 +02:00
2015-12-16 21:23:36 +02:00
2015-12-16 21:23:36 +02:00
2016-06-08 13:27:34 +02:00
2015-12-23 16:29:48 +11:00
2015-12-16 21:23:36 +02:00
2016-03-29 17:43:06 +07:00
2015-11-04 13:38:51 -08:00
2016-04-03 23:04:46 +10:00
2015-12-16 21:23:36 +02:00
2016-01-25 10:26:36 +02:00
2015-12-16 21:23:36 +02:00
2016-06-08 15:06:39 +02:00
2016-03-29 17:43:16 +07:00
2015-12-16 21:23:36 +02:00
2016-04-13 18:26:02 -04:00
2015-12-16 21:23:36 +02:00
2016-03-29 17:43:27 +07:00
2015-12-16 21:23:36 +02:00
2016-06-04 23:35:23 +10:00
2015-12-16 21:23:36 +02:00

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);
            }
        }
    }
}