ServiceLicenseProvider

Namespace: Babel.Licensing Assembly: Babel.Licensing.dll

Represents an abstract class for providing service-based license validation.

public abstract class ServiceLicenseProvider : IAsyncLicenseProvider, ILicenseProvider

Inheritance

objectServiceLicenseProvider

Derived

BabelServiceLicenseProvider, BabelServiceRegistryLicenseProvider

Implements

IAsyncLicenseProvider, ILicenseProvider

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

ServiceLicenseProvider(BabelLicensing)

Initializes a new instance of the class.

public ServiceLicenseProvider(BabelLicensing service)

Parameters

NameDescription

The BabelLicensing service.

Properties

DeleteLicenseWhenRevoked

Gets or sets a value indicating whether the license should be deleted when it is revoked.

public bool DeleteLicenseWhenRevoked { get; set; }

Property Value

bool

FailTolerance

Gets or sets the number of times a license can fail remote validation before the locally cached license is deleted. This property is only used if ThrowExceptionWhenServiceUnavailable is set to false. If set to 0, the locally cached license will never be deleted.

public int FailTolerance { get; set; }

Property Value

int

LicenseRefreshInterval

The interval at which the license will be validated with the remote server, instead of using the cached license key. If set to TimeSpan.Zero, the license will always be validated with the remote server.

public TimeSpan LicenseRefreshInterval { get; set; }

Property Value

TimeSpan

Service

The BabelLicensing service instance.

protected BabelLicensing Service { get; }

Property Value

BabelLicensing

ThrowExceptionWhenServiceUnavailable

Gets or sets a value indicating whether an exception should be thrown when the service is unavailable. If set to false, the cached license key will be used instead.

public bool ThrowExceptionWhenServiceUnavailable { get; set; }

Property Value

bool

UserKey

Gets or sets the user key associated with the activated license.

public string UserKey { get; }

Property Value

string

Methods

CreateServiceLicenseContext(ILicenseContext)

Create the service license context.

protected virtual IServiceLicenseContext CreateServiceLicenseContext(ILicenseContext context)

Parameters

NameDescription

The current license context.

Returns

NameDescription

The service license context.

DeleteServiceStore()

Deletes the local license store.

protected virtual void DeleteServiceStore()

GetLicenseAsync(ILicenseContext, Type, object, CancellationToken)

Gets a license for the specified context, type, and instance asynchronously.

public Task<ILicense> GetLicenseAsync(ILicenseContext context, Type type, object instance, CancellationToken cancellationToken = default)

Parameters

NameDescription

The license context.

type Type

The type requesting the license.

instance object

The instance requesting the license.

cancellationToken CancellationToken

The cancellation token.

Returns

NameDescription

A valid license for the specified context, type, and instance.

GetServiceStore()

Retrieves the service license store associated with the current license provider.

protected abstract IServiceLicenseStore GetServiceStore()

Returns

NameDescription

An instance of representing the service license store.

GetUserKey()

Get the user key associated with the activated license.

protected virtual string GetUserKey()

Returns

NameDescription

The user key associated with the license.

OnFloatingLicenseLost(string, string, Exception)

Raise the event when a floating license is lost.

protected virtual void OnFloatingLicenseLost(string userKey, string licenseToken, Exception error)

Parameters

NameDescription

userKey string

The user key.

licenseToken string

The license token.

error Exception

The error that caused the floating license to be lost.

OnLicenseActivated(object, LicenseActivatedEventArgs)

Handles the event when a license is activated.

protected virtual void OnLicenseActivated(object sender, LicenseActivatedEventArgs e)

Parameters

NameDescription

sender object

The source of the event.

The instance containing the event data.

OnLicenseDeactivated(object, LicenseDeactivatedEventArgs)

Handles the event when a license is deactivated.

protected virtual void OnLicenseDeactivated(object sender, LicenseDeactivatedEventArgs e)

Parameters

NameDescription

sender object

The source of the event.

The instance containing the event data.

OnLicenseDeactivationError(object, LicenseDeactivationErrorEventArgs)

Handles the event when there's an error during license deactivation.

protected virtual void OnLicenseDeactivationError(object sender, LicenseDeactivationErrorEventArgs e)

Parameters

NameDescription

sender object

The source of the event.

The instance containing the event data.

OnLicenseValidated(object, LicenseValidatedEventArgs)

Handles the event when a license is validated.

protected virtual void OnLicenseValidated(object sender, LicenseValidatedEventArgs e)

Parameters

NameDescription

sender object

The source of the event.

The instance containing the event data.

OnLicenseValidationError(object, LicenseValidationErrorEventArgs)

Handles the event when there's an error during license validation.

protected virtual void OnLicenseValidationError(object sender, LicenseValidationErrorEventArgs e)

Parameters

NameDescription

sender object

The source of the event.

The instance containing the event data.

ValidateLicenseKey(string, ILicenseContext, Type, object)

Validates the license key.

protected virtual ILicense ValidateLicenseKey(string licenseKey, ILicenseContext context, Type type, object instance)

Parameters

NameDescription

licenseKey string

The license key.

A

type Type

A

instance object

An object that is requesting the license.

Returns

NameDescription

A valid object.

FloatingLicenseLost

Occurs when a floating license is lost.

public event EventHandler<FloatingLicenseLostEventArgs> FloatingLicenseLost

Event Type

EventHandler<FloatingLicenseLostEventArgs>

Last updated