builder.Services
.AddOptions<ServiceBusSettings>()
.Bind(builder.Configuration.GetSection("Infrastructure:ServiceBus"))
.Validate(options =>
{
var properties = typeof(ServiceBusSettings).GetProperties();
foreach (var property in properties)
{
if (property.GetValue(options) == null)
return false;
}
return true;
}, $"None of the {typeof(ServiceBusSettings).Name} properties can be empty")
.ValidateOnStart();
builder.Services
.AddOptions<ServiceBusSettings>()
.Bind(builder.Configuration.GetSection("Infrastructure:ServiceBus"))
.Validate(options =>
{
var properties = typeof(ServiceBusSettings).GetProperties();
foreach (var property in properties)
{
if (property.GetValue(options) == null)
return false;
}
return true;
}, $"None of the {typeof(ServiceBusSettings).Name} properties can be empty")
.ValidateOnStart();