ComponentFactory.Krypton.Ribbon.EncryptedLicenseProvider.InstallLicense C# (CSharp) Méthode

InstallLicense() public méthode

Install a license for the given type.
This method is used by client applications to allow customers to register license for components. The generic Infralution.Licensing.LicenseInstallForm uses this method to install licenses. Client components may implement their own registration forms that call this method. You must call SetParameters before using this method.
public InstallLicense ( Type type, string licenseKey ) : EncryptedLicense
type System.Type The type to install the license for
licenseKey string The license key to install
Résultat EncryptedLicense
        public virtual EncryptedLicense InstallLicense(Type type, string licenseKey)
        {
            // Create an instance of the provider to validate the license
            EncryptedLicense license = LoadLicense(LicenseManager.CurrentContext, type, licenseKey);
            if (license != null)
            {
                // Grab information we need for putting license into the registry
                string version = LicenseInstallForm.GetVersionCode(license.ProductInfo);
                string product = LicenseInstallForm.GetProductCode(license.ProductInfo);

                // Open (create if not present) the version specific path
                string versionPath = _licensePath + version;
                RegistryKey versionKey = Registry.CurrentUser.OpenSubKey(versionPath, true);
                if (versionKey == null)
                    versionKey = Registry.CurrentUser.CreateSubKey(versionPath);
                if (versionKey != null)
                {
                    // Write the license key into the product code entry
                    versionKey.SetValue(product, licenseKey, RegistryValueKind.String);
                }
            }
            return license;
        }