示例#1
0
 private void CacheLicense(License license)
 {
     this.cachedLicense = license;
     try
     {
         this.cachedIsRegistered = LicenseVerificator.IsValid(license, DateTime.UtcNow);
     }
     catch (Exception ex)
     {
         Log.ReportException(ex);
         this.cachedIsRegistered = false;
     }
     this.licenseIsCached = true;
 }
示例#2
0
        public bool IsValidKey(string key)
        {
            bool result;

            try
            {
                key = KeyStringFormatter.ParseKey(key);
                License license = LicenseConverter.KeyToLicense(this.decoder, key);
                result = LicenseVerificator.IsValid(license, DateTime.UtcNow);
            }
            catch (LicensingException)
            {
                result = false;
            }
            return(result);
        }
示例#3
0
        public bool RegisterKey(string key)
        {
            key = KeyStringFormatter.ParseKey(key);
            License license = LicenseConverter.KeyToLicense(this.decoder, key);

            if (!LicenseVerificator.IsValid(license, DateTime.UtcNow))
            {
                return(false);
            }
            this.privateStorer.SaveKey(key);
            this.CacheLicense(license);
            if (this.RegistrationChanged != null)
            {
                this.RegistrationChanged(this);
            }
            return(true);
        }