using Microsoft.Extensions.DependencyInjection;
namespace IronLicensing.Client.Extensions;
public static class ServiceCollectionExtensions
{
///
/// Adds IronLicensing client services to the service collection
///
/// The service collection
/// Configuration action for licensing options
/// The service collection for chaining
public static IServiceCollection AddIronLicensing(this IServiceCollection services, Action configure)
{
services.Configure(configure);
// Core services
services.AddHttpClient();
services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
return services;
}
///
/// Adds IronLicensing client services with simplified configuration
///
/// The service collection
/// Your public API key (pk_live_xxx or pk_test_xxx)
/// Your product slug identifier
/// The service collection for chaining
public static IServiceCollection AddIronLicensing(this IServiceCollection services, string publicKey, string productSlug)
{
return services.AddIronLicensing(options =>
{
options.PublicKey = publicKey;
options.ProductSlug = productSlug;
});
}
///
/// Adds IronLicensing client services with custom API URL (for self-hosted installations)
///
/// The service collection
/// Your public API key
/// Your product slug identifier
/// Custom API base URL
/// The service collection for chaining
public static IServiceCollection AddIronLicensing(
this IServiceCollection services,
string publicKey,
string productSlug,
string apiBaseUrl)
{
return services.AddIronLicensing(options =>
{
options.PublicKey = publicKey;
options.ProductSlug = productSlug;
options.ApiBaseUrl = apiBaseUrl;
});
}
}