Skip to content

Latest commit

 

History

History
81 lines (57 loc) · 2.66 KB

File metadata and controls

81 lines (57 loc) · 2.66 KB

SharedMauiCoreLibrary.Licensing

A shared library, which enables licensing of your .NET MAUI applications.

Dependencies

This extension needs a WooCommerce powered store and the WP Software License Plugin (https://wpsoftwarelicense.com/)

Documentation

Learn more here: https://andreas-reitberger.de/en/docs/programmieren/net-maui-basis-applikation-app-template/lizenz-manager/

Nuget

Get the latest version from nuget.org
NuGet NuGet

Available content

Please find a list of available content below.

Usage

Namespace

xmlns:behaviors="clr-namespace:AndreasReitberger.Shared.Core.Licensing;assembly=SharedMauiCoreLibrary.Licensing"
using AndreasReitberger.Shared.Core.Licensing

LicenseManager

In order to use LicenseManager, create a new Instance like shown below. .

string licenseUri = "andreas-reitberger.de";
LicenseManager manager;

//....

manager = new LicenseManager.LicenseManagerConnectionBuilder()
            .WithLicenseServer(serverAddress: licenseUri, port: null, https: true)
            .Build();

For the licenseUri use the base WordPress store address without https:\\ (like shown above).

LicenseInfo

The next step is to create a ILicenseInfo with the details of your product created in your WooCommerece store.

    info = new LicenseInfo.LicenseInfoBuilder()
        .WithLicense("The license key you want to check")
        .WithOptions(new LicenseOptions()
        {
            ProductName = "Name of your product",
            ProductIdentifier = "Your unique ProductId",
            LicenseCheckPattern = "^AR-((\\w{8})-){2}(\\w{8})$",
        })
        .Build();

Endpoints

If all is setup, you can perform following methods depending on your needs. All will return an ILicenseQueryResult object.

    ILicenseQueryResult result = await manager.CheckLicenseAsync(license: info, LicenseServerTarget.WooCommerce);
    Assert.IsTrue(result?.Success == true);

    result = await manager.DeactivateLicenseAsync(license: info, LicenseServerTarget.WooCommerce);
    Assert.IsTrue(result?.Success == true);

    result = await manager.CheckLicenseAsync(license: info, LicenseServerTarget.WooCommerce);
    Assert.IsTrue(result?.Success == false);

    result = await manager.ActivateLicenseAsync(license: info, LicenseServerTarget.WooCommerce);
    Assert.IsTrue(result?.Success == true);