49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using IronLicensing.Client.Models;
|
|
|
|
namespace IronLicensing.Client;
|
|
|
|
public interface ILicenseManager
|
|
{
|
|
// State
|
|
LicenseInfo? CurrentLicense { get; }
|
|
LicenseStatus Status { get; }
|
|
bool IsLicensed { get; }
|
|
bool IsTrial { get; }
|
|
int TrialDaysRemaining { get; }
|
|
|
|
// Events
|
|
event EventHandler<LicenseChangedEventArgs>? LicenseChanged;
|
|
event EventHandler<LicenseValidationEventArgs>? ValidationCompleted;
|
|
|
|
// Operations
|
|
Task<LicenseResult> ValidateAsync(string? licenseKey = null);
|
|
Task<LicenseResult> ActivateAsync(string licenseKey);
|
|
Task<bool> DeactivateAsync();
|
|
Task<CheckoutResult> StartPurchaseAsync(string tierId, string customerEmail);
|
|
|
|
// Feature Gating
|
|
bool HasFeature(string featureKey);
|
|
Task<bool> HasFeatureAsync(string featureKey);
|
|
void RequireFeature(string featureKey);
|
|
|
|
// Trial
|
|
Task<bool> StartTrialAsync(string email);
|
|
|
|
// Cache management
|
|
Task ClearCacheAsync();
|
|
}
|
|
|
|
public class LicenseChangedEventArgs : EventArgs
|
|
{
|
|
public LicenseInfo? OldLicense { get; init; }
|
|
public LicenseInfo? NewLicense { get; init; }
|
|
}
|
|
|
|
public class LicenseValidationEventArgs : EventArgs
|
|
{
|
|
public bool Success { get; init; }
|
|
public LicenseInfo? License { get; init; }
|
|
public string? ErrorCode { get; init; }
|
|
public string? ErrorMessage { get; init; }
|
|
}
|