| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="ProgressMessage.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System.Globalization; |
| | | 8 | | |
| | | 9 | | namespace MyNet.Utilities.Progress; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Represents a localizable progress message with optional format parameters. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="Message">The message string. May contain format placeholders (e.g. <c>{0}</c>) resolved by <paramref na |
| | | 15 | | /// <param name="Parameters">Optional format parameters passed to <see cref="string.Format(string, object[])"/> when <se |
| | | 16 | | public sealed record ProgressMessage(string Message, params object[] Parameters) |
| | | 17 | | { |
| | | 18 | | /// <summary> |
| | | 19 | | /// Returns the formatted message string. |
| | | 20 | | /// When <see cref="Parameters"/> is non-empty the message is treated as a composite-format string; |
| | | 21 | | /// otherwise the raw <see cref="Message"/> value is returned. |
| | | 22 | | /// </summary> |
| | | 23 | | public override string ToString() |
| | 42 | 24 | | => Parameters.Length > 0 |
| | 42 | 25 | | ? string.Format(CultureInfo.CurrentCulture, Message, Parameters) |
| | 42 | 26 | | : Message; |
| | | 27 | | } |
| | | 28 | | |