stabilizaiton work - projects rework for maintenanceability and ui livening
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StellaOps.Configuration;
|
||||
|
||||
public sealed partial class StellaOpsAuthorityOptions
|
||||
{
|
||||
private static void ValidateLifetime(TimeSpan value, string propertyName, TimeSpan maximum)
|
||||
{
|
||||
if (value <= TimeSpan.Zero)
|
||||
{
|
||||
throw new InvalidOperationException($"Authority configuration requires {propertyName} to be greater than zero.");
|
||||
}
|
||||
|
||||
if (value > maximum)
|
||||
{
|
||||
throw new InvalidOperationException($"Authority configuration requires {propertyName} to be less than or equal to {maximum}.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void NormaliseList(IList<string> values)
|
||||
{
|
||||
if (values.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var unique = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
for (var index = values.Count - 1; index >= 0; index--)
|
||||
{
|
||||
var entry = values[index];
|
||||
|
||||
if (string.IsNullOrWhiteSpace(entry))
|
||||
{
|
||||
values.RemoveAt(index);
|
||||
continue;
|
||||
}
|
||||
|
||||
var trimmed = entry.Trim();
|
||||
if (!unique.Add(trimmed))
|
||||
{
|
||||
values.RemoveAt(index);
|
||||
continue;
|
||||
}
|
||||
|
||||
values[index] = trimmed;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user