using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.Linq; namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] public class License : LicenseMetadata { public License( string key, string name, string url, string htmlUrl, bool featured, string description, string category, string implementation, string body, IEnumerable required, IEnumerable permitted, IEnumerable forbidden) : base(key, name, url) { Ensure.ArgumentNotNull(htmlUrl, "htmlUrl"); Ensure.ArgumentNotNull(description, "description"); Ensure.ArgumentNotNull(category, "category"); Ensure.ArgumentNotNull(implementation, "implementation"); Ensure.ArgumentNotNull(body, "body"); Ensure.ArgumentNotNull(required, "required"); Ensure.ArgumentNotNull(permitted, "permitted"); Ensure.ArgumentNotNull(forbidden, "forbidden"); HtmlUrl = htmlUrl; Featured = featured; Description = description; Category = category; Implementation = implementation; Body = body; Required = new ReadOnlyCollection(required.ToList()); Permitted = new ReadOnlyCollection(permitted.ToList()); Forbidden = new ReadOnlyCollection(forbidden.ToList()); } public License() { } /// /// Url to the license on https://choosealicense.com /// public string HtmlUrl { get; protected set; } /// /// Whether the license is one of the licenses featured on https://choosealicense.com /// public bool Featured { get; protected set; } /// /// A description of the license. /// public string Description { get; protected set; } /// /// A group or family that the license belongs to such as the GPL family of licenses. /// public string Category { get; protected set; } /// /// Notes on how to properly apply the license. /// public string Implementation { get; protected set; } /// /// Set of codes for what is required under the terms of the license. For example, "include-copyright" /// public IReadOnlyList Required { get; protected set; } /// /// Set of codes for what is permitted under the terms of the license. For example, "commercial-use" /// public IReadOnlyList Permitted { get; protected set; } /// /// Set of codes for what is forbidden under the terms of the license. For example, "no-liability" /// public IReadOnlyList Forbidden { get; protected set; } /// /// The text of the license /// public string Body { get; protected set; } internal override string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "{0} Category: {1}", base.DebuggerDisplay, Category); } } } }