Streamline tree API a bit

This commit is contained in:
Patrik Svensson
2021-01-02 10:47:29 +01:00
committed by Patrik Svensson
parent b136d0299b
commit 4bfb24bfcb
13 changed files with 245 additions and 228 deletions

View File

@ -1,20 +0,0 @@
namespace Spectre.Console.Rendering
{
/// <summary>
/// Represents the characters used to render a tree.
/// </summary>
public interface ITreeRendering
{
/// <summary>
/// Get the set of characters used to render the corresponding <see cref="TreePart"/>.
/// </summary>
/// <param name="part">The part of the tree to get rendering string for.</param>
/// <returns>Rendering string for the tree part.</returns>
string GetPart(TreePart part);
/// <summary>
/// Gets the length of all tree part strings.
/// </summary>
int PartSize { get; }
}
}

View File

@ -5,10 +5,13 @@ namespace Spectre.Console.Rendering
/// <summary>
/// An ASCII rendering of a tree.
/// </summary>
public sealed class AsciiTreeRendering : ITreeRendering
public sealed class AsciiTreeAppearance : TreeAppearance
{
/// <inheritdoc/>
public string GetPart(TreePart part)
public override int PartSize => 4;
/// <inheritdoc/>
public override string GetPart(TreePart part)
{
return part switch
{
@ -18,8 +21,5 @@ namespace Spectre.Console.Rendering
_ => throw new ArgumentOutOfRangeException(nameof(part), part, "Unknown tree part."),
};
}
/// <inheritdoc/>
public int PartSize => 4;
}
}

View File

@ -1,13 +0,0 @@
namespace Spectre.Console.Rendering
{
/// <summary>
/// Selection of different renderings which can be used by <see cref="Tree"/>.
/// </summary>
public static class TreeRendering
{
/// <summary>
/// Gets ASCII rendering of a tree.
/// </summary>
public static ITreeRendering Ascii { get; } = new AsciiTreeRendering();
}
}