| using OfficeOpenXml.FormulaParsing.Excel.Functions; |
| using OfficeOpenXml.FormulaParsing.ExpressionGraph; |
| using OfficeOpenXml.FormulaParsing.LexicalAnalysis; |
| using OfficeOpenXml.FormulaParsing.Logging; |
| using OfficeOpenXml.FormulaParsing.Utilities; |
| |
| namespace OfficeOpenXml.FormulaParsing; |
| |
| public class ParsingConfiguration { |
| public virtual ILexer Lexer { get; private set; } |
| |
| public IFormulaParserLogger Logger { get; private set; } |
| |
| public IExpressionGraphBuilder GraphBuilder { get; private set; } |
| |
| public IExpressionCompiler ExpressionCompiler { get; private set; } |
| |
| public FunctionRepository FunctionRepository { get; private set; } = FunctionRepository.Create(); |
| |
| private ParsingConfiguration() {} |
| |
| internal static ParsingConfiguration Create() { |
| return new(); |
| } |
| |
| public ParsingConfiguration SetLexer(ILexer lexer) { |
| Lexer = lexer; |
| return this; |
| } |
| |
| public ParsingConfiguration SetGraphBuilder(IExpressionGraphBuilder graphBuilder) { |
| GraphBuilder = graphBuilder; |
| return this; |
| } |
| |
| public ParsingConfiguration SetExpresionCompiler(IExpressionCompiler expressionCompiler) { |
| ExpressionCompiler = expressionCompiler; |
| return this; |
| } |
| |
| /// <summary> |
| /// Attaches a logger, errors and log entries will be written to the logger during the parsing process. |
| /// </summary> |
| /// <param name="logger"></param> |
| /// <returns></returns> |
| public ParsingConfiguration AttachLogger(IFormulaParserLogger logger) { |
| Require.That(logger).Named("logger").IsNotNull(); |
| Logger = logger; |
| return this; |
| } |
| |
| /// <summary> |
| /// if a logger is attached it will be removed. |
| /// </summary> |
| /// <returns></returns> |
| public ParsingConfiguration DetachLogger() { |
| Logger = null; |
| return this; |
| } |
| } |