using IronServices.Client;
using IronServices.Maui.Services;
using Microsoft.Extensions.DependencyInjection;
namespace IronServices.Maui;
///
/// Extension methods for registering IronServices with MAUI dependency injection.
///
public static class ServiceCollectionExtensions
{
///
/// Adds IronServicesClient with secure token storage for MAUI apps using default URLs.
///
/// The service collection.
/// The service collection for chaining.
public static IServiceCollection AddIronServices(this IServiceCollection services)
{
return services.AddIronServices(_ => { });
}
///
/// Adds IronServicesClient with secure token storage and custom configuration.
///
/// The service collection.
/// Configuration action for the client options.
/// The service collection for chaining.
public static IServiceCollection AddIronServices(this IServiceCollection services, Action configure)
{
var options = new IronServicesClientOptions();
configure(options);
services.AddSingleton();
services.AddSingleton(sp =>
{
var tokenStorage = sp.GetRequiredService();
return new IronServicesClient(options, tokenStorage);
});
return services;
}
}