11namespace ServiceControl . LicenseManagement
22{
33 using System ;
4+ using System . Linq ;
5+ using System . Text . RegularExpressions ;
46 using Particular . Licensing ;
57
68 public class LicenseDetails
@@ -24,6 +26,7 @@ public class LicenseDetails
2426 public bool WarnUserUpgradeProtectionIsExpiring { get ; private init ; }
2527 public bool WarnUserUpgradeProtectionHasExpired { get ; private init ; }
2628 public string Status { get ; private init ; }
29+ public LicensedProduct [ ] Products { get ; private init ; }
2730
2831 public static LicenseDetails TrialFromEndDate ( DateOnly endDate )
2932 {
@@ -64,6 +67,8 @@ internal static LicenseDetails FromLicense(License license)
6467 IsTrialLicense = license . IsTrialLicense ,
6568 LicenseType = license . LicenseType ,
6669 Edition = license . Edition ,
70+ //strip any internal prefix from what gets displayed to the customer
71+ Products = license . LicensedEndpoints ? . Select ( le => new LicensedProduct ( le . Size . EndsWith ( "U" ) ? "Unlimited" : Regex . Replace ( le . Size , @"^\D*" , "" ) , le . Quantity ) ) . ToArray ( ) ,
6772 ValidForServiceControl = license . ValidForApplication ( "ServiceControl" ) ,
6873 DaysUntilSubscriptionExpires = license . GetDaysUntilLicenseExpires ( ) ,
6974 DaysUntilUpgradeProtectionExpires = license . GetDaysUntilUpgradeProtectionExpires ( ) ,
@@ -95,4 +100,6 @@ static bool HasLicenseDateExpired(DateTime licenseDate)
95100 return oneDayGrace < DateTime . UtcNow . Date ;
96101 }
97102 }
103+
104+ public record LicensedProduct ( string Name , int Quantity ) ;
98105}
0 commit comments