namespace WCTDataMiner.Core.Parsers;
///
/// 通用解析器接口
///
public interface IParser
{
///
/// 判断是否可以解析该行
///
bool CanParse(string line);
///
/// 解析日志行
///
/// 日志行内容
/// 关联的测试场景ID
ParseResult Parse(string line, Guid scenarioId);
}
///
/// 解析结果
///
public record ParseResult
{
public bool IsSuccess { get; init; }
public TRecord? Record { get; init; }
public string? ErrorType { get; init; }
public string? ErrorMessage { get; init; }
public static ParseResult Success(TRecord record) =>
new() { IsSuccess = true, Record = record };
public static ParseResult Failure(string errorType, string errorMessage) =>
new() { IsSuccess = false, ErrorType = errorType, ErrorMessage = errorMessage };
}