Show / Hide Table of Contents

Class ErrorLicenseEventArgs

Provides data for the LicenseChanged event in case of an error.

Inheritance
System.Object
System.EventArgs
LicenseEventArgs
ErrorLicenseEventArgs
LicenseEventArgs.Action
LicenseEventArgs.Added
LicenseEventArgs.Changed
LicenseEventArgs.Removed
LicenseEventArgs.FilterExpired(IEnumerable<FeatureInfo>)
LicenseEventArgs.GetChanges(IEnumerable<FeatureInfo>, IEnumerable<FeatureInfo>)
System.EventArgs.Empty
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Sartorius.SAF.Licensing
Assembly: Sartorius.SAF.Licensing.dll
Syntax
public sealed class ErrorLicenseEventArgs : LicenseEventArgs
Remarks

This derived class is only used when there is a daily license check for expired modules. When applying keys and an exception occurs no event is raised. Exceptions thrown when applying keys should be handled directly.

Examples

The following example shows how to use the LicenseChanged event to handle license changes.

    [ImportingConstructor]
    public LicenseConsumer(ILicenseProvider licenseProvider)
    {
        this.licenseProvider = licenseProvider ?? throw new ArgumentNullException(nameof(licenseProvider));

        this.licenseProvider.LicenseChanged += OnLicenseChanged;
    }

    private void OnLicenseChanged(Object sender, LicenseEventArgs licenseEventArgs)
    {
        switch (licenseEventArgs.Action)
        {
            case LicenseEventAction.Expired:
                // one or more feature licenses have expired
                // this is called from a worker thread
                // remove the features from the application
                RemoveFeatures(licenseEventArgs.Removed);
                // Show information to the user about the expired features
                ShowInfo(licenseEventArgs.Removed);
                break;
            case LicenseEventAction.Changed:
                // a change of license occured. This happens when keys are applied.
                // add the feature functionality to the application
                AddFeatures(licenseEventArgs.Added);
                // remove features that are no longer available
                RemoveFeatures(licenseEventArgs.Removed);
                // update feature functionality for changed features (e.g. expiration date has been updated, license count has been updated)
                ChangeFeatures(licenseEventArgs.Changed);
                break;
            case LicenseEventAction.Error:
                // an error occured when there was a timed check for expired modules
                // throw the exception in the UI thread and let the global exception handler take care of application shutdown.
                Application.Current.Dispatcher.BeginInvoke(new Action(((ErrorLicenseEventArgs) licenseEventArgs).Throw));
                // or use ErrorLicenseEventArgs::Exception to handle the exception here.
                // keep in mind this runs on a background thread.
                break;
            default:
                throw new ArgumentOutOfRangeException(nameof(licenseEventArgs));
        }
    }

Constructors

View Source

ErrorLicenseEventArgs(Exception)

Initializes a new instance of the ErrorLicenseEventArgs class.

Declaration
public ErrorLicenseEventArgs(Exception exception)
Parameters
Type Name Description
System.Exception exception

The exception that occured.

Properties

View Source

Exception

Gets the exception that occured while checking the license.

Declaration
public Exception Exception { get; }
Property Value
Type Description
System.Exception

The exception that occured while checking the license.

Methods

View Source

Throw()

Throws the Exception after restoring the state that was saved when the exception was captured.

Declaration
public void Throw()

Extension Methods

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

See Also

LicenseEventArgs
  • View Source
Back to top Generated by DocFX