public async Task <RepositoryLicense> LoadOrCreateLicenseAsync(string licenseCode, CancellationToken token) { licenseCode.AssertNotNull(nameof(licenseCode)); var index = await Storage.ReadLicenseIndexJsonAsync(licenseCode, token); if (index != null) { return(new RepositoryLicense(index.Code, index.RequiresApproval, index.RequiresThirdPartyNotices, index.Dependencies)); } var info = await Container.Resolve <ILicenseResolver>().DownloadByCodeAsync(licenseCode, token); if (info == null) { info = new LicenseInfo { Code = licenseCode, FileName = "license.txt", FileContent = Array.Empty <byte>() }; } index = new LicenseIndexJson { Code = info.Code, FullName = info.FullName, HRef = info.FileHRef, FileName = info.FileName, RequiresApproval = true, RequiresThirdPartyNotices = false }; await Storage.CreateLicenseIndexJsonAsync(index, token); await Storage.CreateLicenseFileAsync(info.Code, info.FileName, info.FileContent, token); return(new RepositoryLicense(index.Code, index.RequiresApproval, index.RequiresThirdPartyNotices, index.Dependencies)); }
public void AddByCode(string code, LicenseInfo info) => _byCode.TryAdd(code, info);
public bool TryGetByCode(string code, out LicenseInfo info) => _byCode.TryGetValue(code, out info);
public void AddByUrl(string url, LicenseInfo info) => _byUrl.TryAdd(url, info);
public bool TryGetByUrl(string url, out LicenseInfo info) => _byUrl.TryGetValue(url, out info);