Show / Hide Table of Contents

Interface ISerialLicenseProvider

Defines methods and properties for license providers that support serials.

IActivationKeysLicenseProvider.ApplyActivationKeys(String[])
IActivationKeysLicenseProvider.GetActivationKeyInfos(String[])
ILicenseProvider.LicenseChanged
ILicenseProvider.ApplyLicense(String)
ILicenseProvider.ApplyLicense(Stream)
ILicenseProvider.Checkin(String)
ILicenseProvider.Checkin(String, Int32)
ILicenseProvider.Checkout(String)
ILicenseProvider.Checkout(String, Int32)
ILicenseProvider.GetFeatureInfo(String)
ILicenseProvider.GetHardwareIds(Int32[])
ILicenseProvider.GetLicenseFileInfo()
System.IDisposable.Dispose()
Namespace: Sartorius.SAF.Licensing
Assembly: Sartorius.SAF.Licensing.dll
Syntax
[InheritedExport]
public interface ISerialLicenseProvider : IActivationKeysLicenseProvider, ILicenseProvider, IDisposable
Remarks

For license providers like the MirageLicenseProvider the serial is an important part of the licensing workflow. See the actual documentation of the license providers for details.

Examples

The following example shows how to set the serial.

        this.serialLicenseProvider.Serial = serial;

        this.serialLicenseProvider.ApplyActivationKeys(unlockKey);

        var info = this.serialLicenseProvider.GetLicenseFileInfo();

        foreach (var featureInfo in info.FeatureInfos)
        {
            // after applying an unlock key some license providers (e.g. the Mirage License Provider) will change the state of features
        }

The following example illustrates the complete licensing workflow using a ISerialLicenseProvider represented by the Mirage license provider.

                // The application is published with a default license file
                // on first start it is a demo version
                // if the demo was started before the demo could have expired now

                // The demo can expire anytime when the application runs. Subscribe to license changes to react to such an expiration.
                licenseProvider.LicenseChanged += OnLicenseChanged;

                // ask for the main feature
                var result = licenseProvider.Checkout("SIM001");
                if (result.State.HasFlag(FeatureState.Licensed))
                {
                    // The feature is available the functionality can be provided to the user
                    // If you are providing a demo or timed licenses, the license state could change during usage of the application
                }

                // for information purposes you could show information about the current license state to the user
                // or check the complete license status for any purpose of your application.
                var licenseInfo = licenseProvider.GetLicenseFileInfo();
                var mainFeatureInfo = licenseInfo.FeatureInfos["SIM001"];

                // When a customer registers and buys licenses deliver the hardware ids to order management
                var hardwareIds = licenseProvider.GetHardwareIds();

                // get some keys (e.g. via user interface, user enters the keys)
                var keys = GetKeys(hardwareIds);

                // if needed the keys can be validated before applying them
                var keyInfos = licenseProvider.GetActivationKeyInfos(keys).ToList();
                foreach (var info in keyInfos.OfType<ProtectionKeyInfo>())
                {
                    // Protection keys actually bond the license file to the hardware.
                    // they contain info about the hardware id and the type of hardware id
                    Trace.WriteLine($"Protection key for '{info.HardwareId}', type {info.ProtectionType}.");
                    Trace.WriteLine($"The key can be applied on this hardware: {info.IsApplicable}.");
                }

                foreach (var info in keyInfos.OfType<FeatureKeyInfo>())
                {
                    // Feature Keys provide licenses for additional features
                    Trace.WriteLine($"Activation key for '{info.FeatureId}' with {info.LicenseCount} licenses, valid for {info.Days}.");
                    Trace.WriteLine($"The key can be applied on hardware with id: {info.HardwareId}.");
                }

                foreach (var info in keyInfos.OfType<InvalidKeyInfo>())
                {
                    // invalid keys cannot be applied to the hardware or are formatted wrongly
                }

                // for correct Mirage workflow set the serial before applying an unlock key
                licenseProvider.Serial = currentSerial;

                // when applying keys the LicenseChanged event will also be raised.
                // So changed to the user interface when activating or deactivating new features can be done in one place.
                licenseProvider.ApplyActivationKeys(keyInfos.OfType<ProtectionKeyInfo>().Single().Key);

                // after applying the keys the keys the license info will reflect the new license state
                licenseInfo = licenseProvider.GetLicenseFileInfo();
                mainFeatureInfo = licenseInfo.FeatureInfos["SIM001"];

Properties

View Source

Serial

Gets or sets the serial.

Declaration
string Serial { get; set; }
Property Value
Type Description
System.String

Extension Methods

CollectionExtensions.AddRange<T, TCollection>(TCollection, IEnumerable<T>)
SerializableObjectCloneExtension.Clone<T>(T)

See Also

MirageLicenseProvider
IActivationKeysLicenseProvider
ILicenseProvider
  • View Source
Back to top Generated by DocFX