Skip to content

.NET quickstart

This page gets the Monaiq .NET client installed, configured and registered in a .NET application, and shows you where the licensing calls come from afterwards.

The package is Sidub.Licensing.Client, and it targets netstandard2.1.

Terminal window
dotnet add package Sidub.Licensing.Client

The client is configured through LicensingServiceOptions and registered with AddSidubLicensing(). In a minimal hosting Program.cs:

var builder = WebApplication.CreateBuilder(args);
builder.Services.Configure<LicensingServiceOptions>(options =>
{
options.LicenseServiceUri = "https://api.monaiq.com/licensing";
options.ConsumptionServiceUri = "https://api.monaiq.com/consumption";
options.EncodedCredential = builder.Configuration["Licensing:EncodedCredential"];
});
builder.Services.AddSidubLicensing();
var app = builder.Build();

Three things are being set:

  • LicenseServiceUri is the licensing API, which answers the authorization and feature questions.
  • ConsumptionServiceUri is the consumption API, which handles metered usage. Consumption and metering covers when you need it.
  • EncodedCredential is your credential, read from configuration rather than written into the file.

Both addresses are the production ones and are listed in Endpoints.

EncodedCredential takes the portable credential string that starts SIDUB_LIC_. The example reads it from the configuration key Licensing:EncodedCredential, which in appsettings.json looks like this:

{
"Licensing": {
"EncodedCredential": "SIDUB_LIC_..."
}
}

Where the value comes from, and how to replace it, is in Credentials and keys.

AddSidubLicensing() registers ILicensingService, which you take from dependency injection wherever you need to make a licensing decision. Its members are:

  • GetAuthorization for the current authorization, which is the starting point for everything else.
  • GetLicenseFeature<T> for a single feature of the license.
  • PerformOperation<TFeature, TState> for work that runs against a feature.
  • AssertLicense for enforcing a condition rather than inspecting one.

Two supporting types come with it: LicensingContextAccessor for the current licensing context, and LicensingServiceReference for identifying the service itself. .NET client reference lists the full surface.

If you would rather not work out the call sites by hand, the AI-assisted path does exactly that: its implement_base and implement_product_feature tools return the wiring and the feature check for your own project, and provision_api_key_config returns the commands and file edits that plumb the credential in. See AI-assisted setup.