using System; using System.Collections.Generic; using System.Text; namespace FrostFS.SDK.ModelsV2; public class ClientSettings { protected static readonly string errorTemplate = "{0} is required parameter"; public string Host { get; set; } = string.Empty; public virtual void Validate() { var errors = CheckFields(); if (errors != null) ThrowException(errors); } protected List? CheckFields() { List? errors = null; if (string.IsNullOrWhiteSpace(Host)) (errors ??= []).Add(string.Format(errorTemplate, nameof(Host))); return errors; } protected static void ThrowException(List errors) { StringBuilder messages = new(); foreach (var error in errors) { messages.AppendLine(error); } throw new ArgumentException(messages.ToString()); } } public class SingleOwnerClientSettings : ClientSettings { public string Key { get; set; } = string.Empty; public override void Validate() { var errors = CheckFields(); if (errors != null) ThrowException(errors); } protected List? CheckFields() { List? errors = base.CheckFields(); if (string.IsNullOrWhiteSpace(Key)) (errors ??= []).Add(string.Format(errorTemplate, nameof(Key))); return errors; } }