50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using System;
|
|
|
|
namespace YLErp.Modules.RiskEngine
|
|
{
|
|
/// <summary>
|
|
/// 规则编译结果。
|
|
/// 用于承载公式校验、Roslyn 编译结果和错误信息。
|
|
/// </summary>
|
|
public class RuleCompileResult
|
|
{
|
|
/// <summary>
|
|
/// 是否编译成功。
|
|
/// </summary>
|
|
public bool Success { get; set; }
|
|
|
|
/// <summary>
|
|
/// 编译失败时的错误信息。
|
|
/// </summary>
|
|
public string ErrorMessage { get; set; }
|
|
|
|
/// <summary>
|
|
/// 编译成功后的可执行委托。
|
|
/// </summary>
|
|
public Func<RiskContext, bool> CompiledScript { get; set; }
|
|
|
|
/// <summary>
|
|
/// 创建成功结果。
|
|
/// </summary>
|
|
public static RuleCompileResult Ok(Func<RiskContext, bool> compiledScript)
|
|
{
|
|
return new RuleCompileResult
|
|
{
|
|
Success = true,
|
|
CompiledScript = compiledScript
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建失败结果。
|
|
/// </summary>
|
|
public static RuleCompileResult Fail(string errorMessage)
|
|
{
|
|
return new RuleCompileResult
|
|
{
|
|
Success = false,
|
|
ErrorMessage = errorMessage
|
|
};
|
|
}
|
|
}
|
|
} |