namespace Store.Management.Api; public sealed class ApiClientOptions { public required Uri BaseUrl { get; init; } public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(30); internal void Validate() { if (BaseUrl is null || !BaseUrl.IsAbsoluteUri || (BaseUrl.Scheme != "https" && BaseUrl.Scheme != "http") || !string.IsNullOrEmpty(BaseUrl.UserInfo) || !string.IsNullOrEmpty(BaseUrl.Query) || !string.IsNullOrEmpty(BaseUrl.Fragment)) throw new ArgumentException("BaseUrl 必须是无凭据、查询参数和片段的 HTTP(S) 绝对地址。"); if (Timeout <= TimeSpan.Zero) throw new ArgumentOutOfRangeException(nameof(Timeout)); } }