using System;
using System.Diagnostics;
using System.Globalization;
using System.Text.RegularExpressions;
namespace Octokit
{
///
/// Describes a new label to create via the method.
///
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class NewLabel
{
private string _color;
///
/// Initializes a new instance of the class.
///
/// The name of the label.
/// The color of the label.
public NewLabel(string name, string color)
{
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(color, nameof(color));
Name = name;
Color = color;
}
///
/// Name of the label (required).
///
///
/// Emoji can be added to label names, using either native emoji or colon-style markup. For example,
/// typing :strawberry: will render the emoji for strawberry. For a full list of available emoji and codes, see http://emoji-cheat-sheet.com/.
///
public string Name { get; set; }
///
/// Color of the label (required).
///
///
/// The hexadecimal color code for the label, without the leading #.
///
public string Color
{
get { return _color; }
set
{
if (!Regex.IsMatch(value, @"\A\b[0-9a-fA-F]{6}\b\Z"))
{
throw new ArgumentOutOfRangeException("value", "Color should be an hexadecimal string of length 6");
}
_color = value;
}
}
///
/// A short description of the label (optional).
///
public string Description { get; set; }
internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture, "Name: {0}", Name);
}
}
}
}