| | 1 | | using System.Globalization; |
| | 2 | | using System.Resources; |
| | 3 | | using ValidateLib.Metadata.ErrorHandling; |
| | 4 | |
|
| | 5 | | namespace ValidateLib.ErrorsAndWarnings.Errors |
| | 6 | | { |
| | 7 | | /// <summary> |
| | 8 | | /// Class representing one validation error. |
| | 9 | | /// </summary> |
| | 10 | | public class Error : ErrorOrWarning |
| | 11 | | { |
| 1 | 12 | | public string? AdditionalInfo { get; set; } |
| 1 | 13 | | protected ResourceManager ErrorManager = new ResourceManager(EWConstants.ErrorResources, typeof(Error).Assembly) |
| 1 | 14 | | public static ResourceManager ErrorManagerPublic = new ResourceManager(EWConstants.ErrorResources, typeof(Error) |
| | 15 | | /// <summary> |
| | 16 | | /// Prefix in the error message. Currently empty. |
| | 17 | | /// </summary> |
| 1 | 18 | | protected string ErrorMessagePrefix { get; set; } = ""; |
| 0 | 19 | | static ResourceManager _ResourceManager { get; set; } = |
| 1 | 20 | | new ResourceManager(EWConstants.PathToResources, typeof(Error).Assembly); |
| | 21 | | /// <summary> |
| | 22 | | /// Contains additional informations that can be shown in the error messages. |
| | 23 | | /// </summary> |
| 1 | 24 | | public ErrorHandlingInfo? ErrorInfo { get; set; } |
| | 25 | | public override ErrorType GetErrorType() |
| | 26 | | { |
| 1 | 27 | | return ErrorType.ERROR; |
| | 28 | | } |
| | 29 | | /// <summary> |
| | 30 | | /// Returns localized error message with parameters formated in the string. |
| | 31 | | /// </summary> |
| | 32 | | /// <param name="className"> Name of the class that is index in the .resx file.</param> |
| | 33 | | /// <param name="cultureInfo"> Culture in which we want to have localized the message.</param> |
| | 34 | | /// <param name="stringArgs"> Arguments of the message. </param> |
| | 35 | | /// <returns> Localized error message. </returns> |
| | 36 | | protected string GetMessageWithParams(string className, CultureInfo cultureInfo, params object?[] stringArgs) |
| | 37 | | { |
| 1 | 38 | | string message = ErrorMessagePrefix + ErrorManager.GetString(className, cultureInfo)!; |
| 1 | 39 | | return string.Format(message, stringArgs); |
| | 40 | | } |
| | 41 | |
|
| | 42 | | } |
| | 43 | | } |