Add Padding extension

Add extension method for specifying horizontal and vertical padding.
Similar constructor for `Padding` already existed.

Update documentation for table column appearance (padding).

Update
`Should_Render_Padded_Object_Correctly_When_Nested_Within_Other_Object`
test to use new extension method.
This commit is contained in:
Martin Andersen
2020-10-26 20:41:49 +01:00
committed by Patrik Svensson
parent 9915a0d6a8
commit bca1c889d1
3 changed files with 23 additions and 5 deletions

View File

@ -80,7 +80,7 @@ namespace Spectre.Console
}
/// <summary>
/// Sets the left and right padding.
/// Sets the left, top, right and bottom padding.
/// </summary>
/// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
/// <param name="obj">The paddable object instance.</param>
@ -95,6 +95,20 @@ namespace Spectre.Console
return Padding(obj, new Padding(left, top, right, bottom));
}
/// <summary>
/// Sets the horizontal and vertical padding.
/// </summary>
/// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
/// <param name="obj">The paddable object instance.</param>
/// <param name="horizontal">The left and right padding.</param>
/// <param name="vertical">The top and bottom padding.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static T Padding<T>(this T obj, int horizontal, int vertical)
where T : class, IPaddable
{
return Padding(obj, new Padding(horizontal, vertical));
}
/// <summary>
/// Sets the padding.
/// </summary>