24 lines
678 B
C#
24 lines
678 B
C#
using RecNet.Domain.Exceptions;
|
|
|
|
namespace RecNet.Domain.Configuration;
|
|
|
|
public class ServerConfig
|
|
{
|
|
private ServerConfig(string key, string value)
|
|
{
|
|
Key = RequireValue(key, nameof(key));
|
|
Value = value;
|
|
}
|
|
|
|
public string Key { get; private set; }
|
|
public string Value { get; private set; }
|
|
|
|
public static ServerConfig Create(string key, string value)
|
|
=> new(key, value);
|
|
|
|
public void SetValue(string value)
|
|
=> Value = value;
|
|
|
|
private static string RequireValue(string value, string parameterName)
|
|
=> !string.IsNullOrWhiteSpace(value) ? value : throw new DomainException($"{parameterName} is required.");
|
|
} |