feat(configmanager): add ConnectionStrings editor with test connection support
Adds a new ConnectionStrings section to ConfigManager allowing users to manage database connection strings with provider selection, connection testing, and visual feedback for connection state.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using System.Globalization;
|
||||
using Avalonia.Data.Converters;
|
||||
using JdeScoping.ConfigManager.Models;
|
||||
|
||||
namespace JdeScoping.ConfigManager.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// Converts a ConnectionProvider value to visibility (bool) based on whether it matches the target provider.
|
||||
/// </summary>
|
||||
public class ProviderToVisibilityConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converter instance for SqlServer provider visibility.
|
||||
/// </summary>
|
||||
public static readonly ProviderToVisibilityConverter SqlServer = new(ConnectionProvider.SqlServer);
|
||||
|
||||
/// <summary>
|
||||
/// Converter instance for Oracle provider visibility.
|
||||
/// </summary>
|
||||
public static readonly ProviderToVisibilityConverter Oracle = new(ConnectionProvider.Oracle);
|
||||
|
||||
/// <summary>
|
||||
/// Converter instance for Generic provider visibility.
|
||||
/// </summary>
|
||||
public static readonly ProviderToVisibilityConverter Generic = new(ConnectionProvider.Generic);
|
||||
|
||||
private readonly ConnectionProvider _targetProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ProviderToVisibilityConverter"/> class.
|
||||
/// </summary>
|
||||
/// <param name="targetProvider">The provider to match for visibility.</param>
|
||||
public ProviderToVisibilityConverter(ConnectionProvider targetProvider)
|
||||
{
|
||||
_targetProvider = targetProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a ConnectionProvider to a boolean indicating visibility.
|
||||
/// </summary>
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is ConnectionProvider provider)
|
||||
{
|
||||
return provider == _targetProvider;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not implemented - this is a one-way converter.
|
||||
/// </summary>
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user