Files
DigitalData.MessagingService/src/core/DigitalData.MessagingService.Application/DependencyInjection/MessagingServiceApplicationConfiguration.cs
TekH 35094529bb Refactor: Remove IServiceCollection dependency
Removed the IServiceCollection dependency and related code from MessagingServiceApplicationConfiguration.cs. This includes the private property `Services`, the boolean field `_luckyPennySoftLicenseKeyAdded`, and the constructor that initialized `Services`. The `EnsureConfigured` method remains, but its functionality may be impacted by these changes.
2026-11-04 11:37:57 +01:00

37 lines
1.4 KiB
C#

#if NET
using Microsoft.Extensions.Configuration;
namespace DigitalData.MessagingService.Application.DependencyInjection;
public partial class MessagingServiceApplicationConfiguration
{
private bool _luckyPennySoftLicenseKeyAdded = false;
internal void EnsureConfigured()
{
if (!_luckyPennySoftLicenseKeyAdded)
{
throw new InvalidOperationException("LuckyPennySoftLicenseKey is not configured. Please call SetLuckyPennySoftLicenseKey() or SetLuckyPennySoftLicenseKey(IConfiguration) in DI configuration.");
}
}
#region LuckyPennySoftLicenseKey
internal string? LuckyPennySoftLicenseKey { get; set; } = null;
public MessagingServiceApplicationConfiguration SetLuckyPennySoftLicenseKey(string licenseKey)
{
if (string.IsNullOrWhiteSpace(licenseKey))
throw new InvalidOperationException("LuckyPennySoftLicenseKey is not configured. Please call SetLuckyPennySoftLicenseKey() or SetLuckyPennySoftLicenseKey(IConfiguration) in DI configuration.");
LuckyPennySoftLicenseKey = licenseKey;
_luckyPennySoftLicenseKeyAdded = true;
return this;
}
public MessagingServiceApplicationConfiguration SetLuckyPennySoftLicenseKey(IConfiguration configuration, string key = "LuckyPennySoftLicenseKey")
{
return SetLuckyPennySoftLicenseKey(configuration.GetValue<string>(key) ?? string.Empty);
}
#endregion LuckyPennySoftLicenseKey
}
#endif