namespace Spectre.Console.Cli;
///
/// Base class for a pair deconstructor.
///
/// The key type.
/// The value type.
public abstract class PairDeconstructor : IPairDeconstructor
{
///
/// Deconstructs the provided into a pair.
///
/// The string to deconstruct into a pair.
/// The deconstructed pair.
protected abstract (TKey Key, TValue Value) Deconstruct(string? value);
///
(object? Key, object? Value) IPairDeconstructor.Deconstruct(ITypeResolver resolver, Type keyType, Type valueType, string? value)
{
if (!keyType.IsAssignableFrom(typeof(TKey)) || !valueType.IsAssignableFrom(typeof(TValue)))
{
throw new InvalidOperationException("Pair destructor is not compatible.");
}
return Deconstruct(value);
}
}
///
/// Base class for a pair deconstructor.
///
/// The key type.
/// The value type.
/// This class is misspelled, use instead.
[Obsolete("Use PairDeconstructor instead")]
public abstract class PairDeconstuctor : PairDeconstructor
{
}