private License LoadLicense() { License license = null; try { string text = this.privateStorer.LoadKey(); if (text != null && text.Length > 0) { license = LicenseConverter.KeyToLicense(this.decoder, text); } else { text = this.publicStorer.LoadKey(); license = LicenseConverter.KeyToLicense(this.decoder, text); } } catch (Exception ex) { Log.ReportException(ex); } if (license != null && LicenseVerificator.IsCorrect(license) && LicenseVerificator.IsPregenerated(license)) { License license2 = this.LoadOldLicense(); if (license2 != null && LicenseVerificator.IsCorrect(license2) && !LicenseVerificator.IsPregenerated(license2)) { if (LicenseVerificator.IsOutdatedForVersion2x(license2)) { license2.UpgradeEvaluation = true; license2.StartTime = license.StartTime; license2.EndTime = license.EndTime; license = license2; } else { license = license2; } } } else { if (license == null) { License license3 = this.LoadOldLicense(); if (license3 != null && LicenseVerificator.IsCorrect(license3)) { license = license3; } } } return(license); }
public static string Format(License license, DateTime now) { if (license == null) { return("No license"); } if (!LicenseVerificator.IsCorrect(license)) { return("Unknown license"); } StringBuilder stringBuilder = new StringBuilder(); if (license.UpgradeEvaluation) { LicenseInformationFormatter.AppendLicenseOutdatedInfo(stringBuilder); LicenseInformationFormatter.AppendUpgradeEvaluationExpirationInfo(stringBuilder, license, now); } else { if (LicenseVerificator.IsOutdatedForVersion2x(license)) { LicenseInformationFormatter.AppendLicenseOutdatedInfo(stringBuilder); } else { LicenseInformationFormatter.AppendLicenseTypeInfo(stringBuilder, license); LicenseInformationFormatter.AppendLicensedToInfo(stringBuilder, license); if (LicenseVerificator.IsTimeLimited(license)) { LicenseInformationFormatter.AppendLicenseExpirationInfo(stringBuilder, license, now); } } } return(stringBuilder.ToString().TrimEnd(new char[] { '\r', '\n' })); }
public static bool IsValid(License license, DateTime now) { return(license != null && LicenseVerificator.IsCorrect(license) && LicenseVerificator.IsStarted(license, now) && !LicenseVerificator.IsExpired(license, now) && !LicenseVerificator.IsOutdatedForVersion2x(license)); }