Ejemplo n.º 1
0
        static StringBuilder ToString(OpenSourceLibrary m, StringBuilder sb)
        {
            sb.AppendLine(hr);
            sb.AppendLine(m.Name);
            sb.AppendLine(hr);
            sb.AppendLine(m.Url);

            if (m.Url != null)
            {
                if (corrections.ContainsKey(m.Url))
                {
                    var(license, copyright) = corrections[m.Url];
                    if (!string.IsNullOrWhiteSpace(license))
                    {
                        m.License = license;
                    }
                    if (!string.IsNullOrWhiteSpace(copyright))
                    {
                        m.Copyright = copyright;
                    }
                }

                if (string.IsNullOrWhiteSpace(m.Copyright) && m.Url.StartsWith("https://github.com", StringComparison.OrdinalIgnoreCase))
                {
                    var urlSplitArray = m.Url.Split('/', StringSplitOptions.RemoveEmptyEntries);
                    if (urlSplitArray.Length >= 3)
                    {
                        m.Copyright = $"Copyright (c) {urlSplitArray[2]}";
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(m.Copyright) && !string.IsNullOrWhiteSpace(m.License) && !string.IsNullOrWhiteSpace(m.LicenseUrl) && !string.Equals("NOASSERTION", m.License, StringComparison.OrdinalIgnoreCase))
            {
                sb.AppendLine();
                sb.AppendLine(m.Copyright);
                sb.AppendLine();
                sb.AppendFormat("Licensed under the {0};{1}{2}", m.License, Environment.NewLine, m.LicenseUrl);
                sb.AppendLine();
            }
            else if (!string.IsNullOrEmpty(m.LicenseText))
            {
                sb.AppendLine();
                sb.AppendLine(m.LicenseText);
            }

            return(sb);
        }
        static StringBuilder ToString(OpenSourceLibrary m, StringBuilder sb)
        {
            sb.AppendLine(hr);
            sb.AppendLine(m.Name);
            sb.AppendLine(hr);
            sb.AppendLine(m.Url);

            if (m.Url != null)
            {
                if (corrections.ContainsKey(m.Url))
                {
                    var(license, copyright, licenseUrl) = corrections[m.Url];
                    if (!string.IsNullOrWhiteSpace(license))
                    {
                        m.License = license;
                    }
                    if (!string.IsNullOrWhiteSpace(copyright))
                    {
                        m.Copyright = copyright;
                    }
                    if (!string.IsNullOrWhiteSpace(licenseUrl))
                    {
                        m.LicenseUrl = licenseUrl;
                    }
                }

                if (string.IsNullOrWhiteSpace(m.Copyright) && m.Url.StartsWith("https://github.com", StringComparison.OrdinalIgnoreCase))
                {
                    var urlSplitArray = m.Url.Split('/', StringSplitOptions.RemoveEmptyEntries);
                    if (urlSplitArray.Length >= 3)
                    {
                        m.Copyright = $"Copyright (c) {urlSplitArray[2]}";
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(m.Copyright) && !string.IsNullOrWhiteSpace(m.License) && !string.IsNullOrWhiteSpace(m.LicenseUrl) && !string.Equals("NOASSERTION", m.License, StringComparison.OrdinalIgnoreCase))
            {
                sb.AppendLine();
                const string prefixCopyright = "## ";
                if (m.Copyright.StartsWith(prefixCopyright))
                {
                    sb.AppendLine(m.Copyright[prefixCopyright.Length..]);