public static void RegisterLicense(string licenseKeyText)
{
JsConfig.InitStatics();
string subId = null;
#if !(PCL || NETSTANDARD1_1)
var hold = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#endif
try
{
var parts = licenseKeyText.SplitOnFirst('-');
subId = parts[0];
int subIdInt;
if (int.TryParse(subId, out subIdInt) && revokedSubs.Contains(subIdInt))
throw new LicenseException("This subscription has been revoked. " + ContactDetails);
var key = PclExport.Instance.VerifyLicenseKeyText(licenseKeyText);
var releaseDate = Env.GetReleaseDate();
if (releaseDate > key.Expiry)
throw new LicenseException("This license has expired on {0} and is not valid for use with this release."
.Fmt(key.Expiry.ToString("d")) + ContactDetails).Trace();
if (key.Type == LicenseType.Trial && DateTime.UtcNow > key.Expiry)
throw new LicenseException("This trial license has expired on {0}."
.Fmt(key.Expiry.ToString("d")) + ContactDetails).Trace();
__activatedLicense = key;
}
catch (Exception ex)
{
if (ex is LicenseException)
throw;
var msg = "This license is invalid." + ContactDetails;
if (!string.IsNullOrEmpty(subId))
msg += " The id for this license is '{0}'".Fmt(subId);
throw new LicenseException(msg).Trace();
}
finally
{
#if !(PCL || NETSTANDARD1_1)
Thread.CurrentThread.CurrentCulture = hold;
#endif
}
}