using JdeScoping.ConfigManager.Models; namespace JdeScoping.ConfigManager.ViewModels.Forms; /// /// ViewModel for editing LDAP configuration section. /// public class LdapFormViewModel : ViewModelBase { private readonly LdapSection _model; private readonly Action _onChanged; public LdapFormViewModel(LdapSection model, Action onChanged) { _model = model ?? throw new ArgumentNullException(nameof(model)); _onChanged = onChanged ?? throw new ArgumentNullException(nameof(onChanged)); } /// /// Gets or sets the server URLs as newline-separated text. /// public string ServerUrlsText { get => string.Join("\n", _model.ServerUrls); set { var urls = value.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); if (!_model.ServerUrls.SequenceEqual(urls)) { _model.ServerUrls = urls; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets the group distinguished name. /// public string GroupDn { get => _model.GroupDn; set { if (_model.GroupDn != value) { _model.GroupDn = value; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets the search base distinguished name. /// public string SearchBase { get => _model.SearchBase; set { if (_model.SearchBase != value) { _model.SearchBase = value; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets the connection timeout in seconds. /// public int ConnectionTimeoutSeconds { get => _model.ConnectionTimeoutSeconds; set { if (_model.ConnectionTimeoutSeconds != value) { _model.ConnectionTimeoutSeconds = value; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets whether to use fake authentication. /// public bool UseFakeAuth { get => _model.UseFakeAuth; set { if (_model.UseFakeAuth != value) { _model.UseFakeAuth = value; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets the admin bypass users as newline-separated text. /// public string AdminBypassUsersText { get => string.Join("\n", _model.AdminBypassUsers); set { var users = value.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); if (!_model.AdminBypassUsers.SequenceEqual(users)) { _model.AdminBypassUsers = users; OnPropertyChanged(); _onChanged(); } } } }