.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.
Install
Section titled “Install”dotnet add package Sidub.Licensing.ClientConfigure and register
Section titled “Configure and register”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:
LicenseServiceUriis the licensing API, which answers the authorization and feature questions.ConsumptionServiceUriis the consumption API, which handles metered usage. Consumption and metering covers when you need it.EncodedCredentialis your credential, read from configuration rather than written into the file.
Both addresses are the production ones and are listed in Endpoints.
Supplying the credential
Section titled “Supplying the credential”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.
Calling the service
Section titled “Calling the service”AddSidubLicensing() registers ILicensingService, which you take from dependency injection
wherever you need to make a licensing decision. Its members are:
GetAuthorizationfor 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.AssertLicensefor 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.
Getting the calls written for you
Section titled “Getting the calls written for you”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.
- Credentials and keys for minting and rotating what you configured above.
- Consumption and metering if your offering meters usage.