| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="TextTruncationOptions.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System; |
| | | 8 | | |
| | | 9 | | namespace MyNet.Text.Truncation; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Options for truncating text. This is used to specify the length to truncate to, the string to truncate with and the |
| | | 13 | | /// </summary> |
| | | 14 | | public sealed record TextTruncationOptions |
| | | 15 | | { |
| | | 16 | | /// <summary> |
| | | 17 | | /// Gets the length to truncate to. This is the total length of the truncated string, including the truncation strin |
| | | 18 | | /// </summary> |
| | | 19 | | public required int Length |
| | | 20 | | { |
| | | 21 | | get; |
| | 300 | 22 | | init => field = value < 0 ? throw new ArgumentOutOfRangeException(nameof(value), "Length must be greater than or |
| | | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets the string to use for truncation. This will be appended to the truncated string if the input string is long |
| | | 27 | | /// </summary> |
| | | 28 | | public string TruncationString |
| | | 29 | | { |
| | | 30 | | get; |
| | 294 | 31 | | init => field = value ?? throw new ArgumentNullException(nameof(value)); |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | = "…"; |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Gets the direction from which to truncate the string. This can be from the left or the right. |
| | | 38 | | /// </summary> |
| | | 39 | | public TruncateFrom Direction { get; init; } = TruncateFrom.Right; |
| | | 40 | | } |
| | | 41 | | |