Exemple #1
0
        /// <summary>
        /// Returns the license format string, with {0} representing the authors, and {1} the copyright date.
        /// </summary>
        public static string GetLicenseFormatString(LicenseType type)
        {
            switch (type)
            {
            case LicenseType.MIT:
                return(LicenseManagement.ReadManifestResource("MIT_FS.txt"));

            case LicenseType.SimplifiedBSD:
                return(LicenseManagement.ReadManifestResource("SimplifiedBSD_FS.txt"));

            case LicenseType.zLibLibPng:
                return(LicenseManagement.ReadManifestResource("Zlib-Libpng_FS.txt"));

            case LicenseType.ISC:
                return(LicenseManagement.ReadManifestResource("ISC_FS.txt"));

            case LicenseType.WTFPLv2:
                return(LicenseManagement.ReadManifestResource("WTFPLv2_FS.txt"));

            case LicenseType.FreePL:
                return(LicenseManagement.ReadManifestResource("FPLv1_FS.txt"));

            case LicenseType.PublicDomain:
                return(LicenseManagement.ReadManifestResource("PublicDomain_FS.txt"));

            case LicenseType.CopyLeft:
            case LicenseType.Commercial:
            case LicenseType.Other:
            default:
                throw new NotSupportedException();
            }
        }
Exemple #2
0
        public void VerifyCompatibility(string napackName, int version, License license)
        {
            if (LicenseManagement.IsSupportedLicense(license.LicenseType) &&
                (LicenseManagement.IsSupportedLicense(this.LicenseType) || this.LicenseType == LicenseManagement.LicenseType.CopyLeft))
            {
                // Supported or copy-left licenses can consume supported licenses.
                return;
            }
            else if (license.LicenseType == LicenseManagement.LicenseType.CopyLeft && this.LicenseType == LicenseManagement.LicenseType.CopyLeft)
            {
                // A copy-left license can *likely* consume another copy-left license.
                // You're not in the supported zone, so minor inconsistencies here are up to tthe end-user to verify.
                return;
            }
            else if ((license.LicenseType == LicenseManagement.LicenseType.Commercial || license.LicenseType == LicenseManagement.LicenseType.Other) &&
                     (this.LicenseType == LicenseManagement.LicenseType.Commercial || this.LicenseType == LicenseManagement.LicenseType.Other))
            {
                // A commercial / other license is compatible with a commerical / other license -- with the end-user performing final validaiton.
                return;
            }

            // Note that this does not catch *all* incompatible cases, especially when delving into the realm of commercial or copy=left.
            throw new InvalidNapackException("The package " + napackName + "." + version + " has an incompatible license with the provided license.");
        }