Oakrey.Applications.License
4.0.5
dotnet add package Oakrey.Applications.License --version 4.0.5
NuGet\Install-Package Oakrey.Applications.License -Version 4.0.5
<PackageReference Include="Oakrey.Applications.License" Version="4.0.5" />
<PackageVersion Include="Oakrey.Applications.License" Version="4.0.5" />
<PackageReference Include="Oakrey.Applications.License" />
paket add Oakrey.Applications.License --version 4.0.5
#r "nuget: Oakrey.Applications.License, 4.0.5"
#:package Oakrey.Applications.License@4.0.5
#addin nuget:?package=Oakrey.Applications.License&version=4.0.5
#tool nuget:?package=Oakrey.Applications.License&version=4.0.5
Oakrey.Applications.License
A .NET 10 WPF library for managing application licenses. It provides signature and threshold-based validation, trial and expiration support, reactive license status via IObservable<bool>, a ready-made LicenseWindow WPF dialog, and a typed exception hierarchy.
Main features
- Multiple validators �
SignatureLicenseValidator,ThresholdLicenseValidator, andEnumerableLicenseValidatorcover the most common validation strategies out of the box. ILicenseService� abstraction for requesting full licenses, requesting trial licenses, and checking local license validity. ExposesIsLicensed,IsTrial,IsExpired,ExpirationDate,LicenseInfo, andLicenseWarning. ImplementsIObservable<bool>for reactive status updates.LicenseWindow� a WPF dialog (extendsDarkWindow) with sign-in, trial request, and "continue without license" flows. Exposed asShowAsync()returning aValidationResult.- Exception hierarchy � typed exceptions for all failure modes (see below).
- Extensible �
ILicenseValidatorandILicenseServicecan be implemented independently.
Architecture
Oakrey.Applications.License
|
+-- Validation
| +-- ILicenseValidator interface
| +-- SignatureLicenseValidator validates cryptographic signature only
| +-- ThresholdLicenseValidator requires N or more matching license keys
| +-- EnumerableLicenseValidator requires all specified keys to match
|
+-- Service
| +-- ILicenseService interface (IObservable<bool>)
|
+-- UI
| +-- LicenseWindow WPF dialog for end-user license activation
|
+-- Exceptions
+-- LicenseException base exception
+-- LicenseManagerException manager-level failure (inherits LicenseException)
+-- LicenseTimeoutException license server connection timeout
Exception hierarchy:
classDiagram
Exception <|-- LicenseException
LicenseException <|-- LicenseManagerException
LicenseException <|-- LicenseTimeoutException
Requirements
- .NET 10 (net10.0-windows10.0.17763)
- Windows (WPF)
- Dependencies:
Oakrey.License,Oakrey.License.Windows,Oakrey.Wpf.Converters
Installation
.NET CLI
dotnet add package Oakrey.Applications.License
Package Manager Console
Install-Package Oakrey.Applications.License
NuGet Package Manager in Visual Studio
Navigate to Tools > NuGet Package Manager > Manage NuGet Packages for Solution, search for Oakrey.Applications.License, and install.
Usage
Validating a license
// Signature only
ILicenseValidator validator = new SignatureLicenseValidator();
bool valid = validator.Validate(validationResult);
// All listed feature keys must be present and non-expired
ILicenseValidator validator = new EnumerableLicenseValidator("feature-a", "feature-b");
bool valid = validator.Validate(validationResult);
// At least 2 of the matching keys must be valid and non-expired
ILicenseValidator validator = new ThresholdLicenseValidator(threshold: 2);
bool valid = validator.Validate(validationResult);
Using ILicenseService
// Validate a locally cached license
ValidationResult result = await licenseService.IsLocalLicenseValid(cancellationToken);
// Request a full license for a user
ValidationResult result = await licenseService.RequestLicense(userId, cancellationToken);
// Request a trial license
ValidationResult result = await licenseService.RequestTrialLicense(cancellationToken);
// React to license status changes
licenseService.Subscribe(isLicensed =>
{
// called whenever license status changes
});
Showing the LicenseWindow
LicenseWindow window = new LicenseWindow(licenseService, appId: "my-app");
window.IsTrialEnabled = true;
window.IsNoLicenseEnabled = false;
ValidationResult result = await window.ShowAsync();
ShowAsync() returns only after the user completes or cancels the flow. If the user closes the window without activating, the application is shut down (default behavior of the close button).
Exception handling
try
{
ValidationResult result = await licenseService.RequestLicense(userId, cancellationToken);
}
catch (LicenseTimeoutException)
{
// License server could not be reached within the timeout period.
}
catch (LicenseManagerException ex)
{
// A manager-level license failure occurred.
}
catch (LicenseException ex)
{
// General license failure.
}
Development notes
LicenseWindowextendsDarkWindowfromOakrey.Applications.UIand must run on the WPF dispatcher thread.ShowAsync()handles dispatcher marshalling internally.- All
ILicenseServicemethods accept aCancellationToken. - The window prevents closing before a result is produced; the only exit without a result triggers
Application.Current.Shutdown().
Project information
| Field | Value |
|---|---|
| Package ID | Oakrey.Applications.License |
| Author | Oakrey |
| License | MIT |
| Repository | ApplicationServices |
| Project URL | oakrey.cz |
| NuGet | Oakrey.Applications.License |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows10.0.17763 is compatible. |
-
net10.0-windows10.0.17763
- Oakrey.Applications.UI (>= 3.0.5)
- Oakrey.License (>= 2.0.1)
- Oakrey.License.Windows (>= 3.0.1)
- Oakrey.Wpf.Converters (>= 2.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.