private void LoadAndApplyLicense() { var licenseText = _licenseService.LoadLicense(LicenseMode); if (string.IsNullOrWhiteSpace(licenseText)) { licenseText = _licenseService.LoadLicense(LicenseMode.ToOpposite()); } ApplyLicense(licenseText); }
protected override async Task <bool> SaveAsync() { var licenseExists = _licenseService.LicenseExists(LicenseMode); var oppositeLicenseMode = LicenseMode.ToOpposite(); var oppositeLicenseExists = _licenseService.LicenseExists(oppositeLicenseMode); if (licenseExists && !oppositeLicenseExists) { return(true); } if (string.IsNullOrWhiteSpace(LicenseInfo.Key)) { return(false); } var validationContext = _licenseValidationService.ValidateLicense(LicenseInfo.Key); if (validationContext.HasErrors) { return(false); } try { _licenseService.SaveLicense(LicenseInfo.Key, LicenseMode); } catch (Exception ex) { Log.Error(ex, $"Failed to save license using '{LicenseMode}'"); await _messageService.ShowErrorAsync(_languageService.GetString("FailedToSaveLicense")); return(false); } if (oppositeLicenseExists) { var messageResult = await _messageService.ShowAsync(string.Format("The license for {0} has been successfully created, would you like to remove license for {1}?", LicenseMode.ToDescriptionText(), oppositeLicenseMode.ToDescriptionText()), "Remove license confirmation", MessageButton.YesNo); if (messageResult == MessageResult.Yes) { _licenseService.RemoveLicense(oppositeLicenseMode); } } return(true); }