using System; using System.Diagnostics; using System.Globalization; namespace Octokit { /// /// Used to create anarbitrary markdown /// /// /// API: https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class NewArbitraryMarkdown { const string _markdown = "markdown"; const string _gfm = "gfm"; /// /// Create an arbitrary markdown /// /// The Markdown text to render /// The rendering mode. Can be either markdown by default or gfm /// /// The repository context. Only taken into account when rendering as gfm /// public NewArbitraryMarkdown(string text, string mode, string context) { Text = text; Mode = GetMode(mode); Context = context; } /// /// Create an arbitrary markdown /// /// The Markdown text to render /// public NewArbitraryMarkdown(string text) : this(text, _markdown, null) { } /// /// Create an arbitrary markdown /// /// The Markdown text to render /// The rendering mode. Can be either markdown by default or gfm public NewArbitraryMarkdown(string text, string mode) : this(text, mode, null) { } /// /// Gets the markdown text /// /// /// The text. /// public string Text { get; private set; } /// /// Gets the mode of the text /// /// /// The mode. /// public string Mode { get; private set; } /// /// Gets the context of the markdown /// /// /// The context. /// public string Context { get; private set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "gfm")] static string GetMode(string mode) { if (mode != _markdown && mode != _gfm) { throw new FormatException("The mode must be either 'markdown' or 'gfm'"); } else return mode; } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Text: {0}", Text); } } } }