- 将核心功能提取到 WCTDataMiner.Core 类库 - 添加 WCTDataMiner.Wpf 桌面应用 - 支持数据解析、导出、统计等功能 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
namespace WCTDataMiner.Core.Parsers;
|
|
|
|
/// <summary>
|
|
/// 通用解析器接口
|
|
/// </summary>
|
|
public interface IParser<TRecord>
|
|
{
|
|
/// <summary>
|
|
/// 判断是否可以解析该行
|
|
/// </summary>
|
|
bool CanParse(string line);
|
|
|
|
/// <summary>
|
|
/// 解析日志行
|
|
/// </summary>
|
|
/// <param name="line">日志行内容</param>
|
|
/// <param name="scenarioId">关联的测试场景ID</param>
|
|
ParseResult<TRecord> Parse(string line, Guid scenarioId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 解析结果
|
|
/// </summary>
|
|
public record ParseResult<TRecord>
|
|
{
|
|
public bool IsSuccess { get; init; }
|
|
public TRecord? Record { get; init; }
|
|
public string? ErrorType { get; init; }
|
|
public string? ErrorMessage { get; init; }
|
|
|
|
public static ParseResult<TRecord> Success(TRecord record) =>
|
|
new() { IsSuccess = true, Record = record };
|
|
|
|
public static ParseResult<TRecord> Failure(string errorType, string errorMessage) =>
|
|
new() { IsSuccess = false, ErrorType = errorType, ErrorMessage = errorMessage };
|
|
} |