public async Task <IEnumerable <License> > GetLicensesAsync()
        {
            const string BASEURL          = "https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json";
            const string USERAGENT_HEADER = "User-Agent";
            const string USERAGENT_VALUE  = "LicenseTracker";

            var results = new List <License>();
            var list    = await BASEURL
                          .WithHeader(USERAGENT_HEADER, USERAGENT_VALUE)
                          .GetJsonAsync <LicenseInfoList>();

            foreach (var licenseInfo in list.Licenses)
            {
                var fullLicenseInfo = await licenseInfo.DetailsUrl
                                      .WithHeader(USERAGENT_HEADER, USERAGENT_VALUE)
                                      .GetJsonAsync <FullLicenseInfo>();

                results.Add(new License
                {
                    Key  = fullLicenseInfo.LicenseId,
                    Name = fullLicenseInfo.Name,
                    Text = fullLicenseInfo.StandardLicenseTemplate
                });
            }

            return(results);
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <License> > GetLicensesAsync()
        {
            const string BASEURL          = "https://api.github.com/licenses";
            const string USERAGENT_HEADER = "User-Agent";
            const string USERAGENT_VALUE  = "LicenseTracker";

            var results = new List <License>();
            var list    = await BASEURL
                          .WithHeader(USERAGENT_HEADER, USERAGENT_VALUE)
                          .GetJsonAsync <IEnumerable <LicenseInfo> >();

            foreach (var licenseInfo in list)
            {
                var fullLicenseInfo = await licenseInfo.Url
                                      .WithHeader(USERAGENT_HEADER, USERAGENT_VALUE)
                                      .GetJsonAsync <FullLicenseInfo>();

                results.Add(new License
                {
                    Key  = fullLicenseInfo.SpdxId,
                    Name = fullLicenseInfo.Name,
                    Text = fullLicenseInfo.Body
                });
            }

            return(results);
        }