using Kean.Domain; namespace Kean.Application.Command.ViewModels { /// /// 失败信息 /// public sealed class Failure { /// /// 根据 FluentValidation.Results.ValidationFailure 创建实例 /// public static implicit operator Failure(NotificationEvent @event) { if (@event == null) { return null; } else { return new() { ErrorCode = @event.ErrorCode, ErrorMessage = @event.ErrorMessage, PropertyName = @event.PropertyName, AttemptedValue = @event.AttemptedValue }; } } /// /// 消息码 /// public object ErrorCode { get; set; } /// /// 消息内容 /// public string ErrorMessage { get; set; } /// /// 属性名 /// public string PropertyName { get; set; } /// /// 属性值 /// public object AttemptedValue { get; set; } /* * 重写 ToString 方法 */ public override string ToString() { return $"{ErrorMessage}({PropertyName}:{AttemptedValue})"; } } }