1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
---|
6 | using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
|
---|
7 | using OfficeOpenXml.FormulaParsing.ExpressionGraph;
|
---|
8 | using OfficeOpenXml.FormulaParsing.Excel.Functions;
|
---|
9 | using OfficeOpenXml.FormulaParsing.Logging;
|
---|
10 | using OfficeOpenXml.FormulaParsing.Utilities;
|
---|
11 |
|
---|
12 | namespace OfficeOpenXml.FormulaParsing
|
---|
13 | {
|
---|
14 | public class ParsingConfiguration
|
---|
15 | {
|
---|
16 | public virtual ILexer Lexer { get; private set; }
|
---|
17 |
|
---|
18 | public IFormulaParserLogger Logger { get; private set; }
|
---|
19 |
|
---|
20 | public IExpressionGraphBuilder GraphBuilder { get; private set; }
|
---|
21 |
|
---|
22 | public IExpressionCompiler ExpressionCompiler{ get; private set; }
|
---|
23 |
|
---|
24 | public FunctionRepository FunctionRepository{ get; private set; }
|
---|
25 |
|
---|
26 | private ParsingConfiguration()
|
---|
27 | {
|
---|
28 | FunctionRepository = FunctionRepository.Create();
|
---|
29 | }
|
---|
30 |
|
---|
31 | internal static ParsingConfiguration Create()
|
---|
32 | {
|
---|
33 | return new ParsingConfiguration();
|
---|
34 | }
|
---|
35 |
|
---|
36 | public ParsingConfiguration SetLexer(ILexer lexer)
|
---|
37 | {
|
---|
38 | Lexer = lexer;
|
---|
39 | return this;
|
---|
40 | }
|
---|
41 |
|
---|
42 | public ParsingConfiguration SetGraphBuilder(IExpressionGraphBuilder graphBuilder)
|
---|
43 | {
|
---|
44 | GraphBuilder = graphBuilder;
|
---|
45 | return this;
|
---|
46 | }
|
---|
47 |
|
---|
48 | public ParsingConfiguration SetExpresionCompiler(IExpressionCompiler expressionCompiler)
|
---|
49 | {
|
---|
50 | ExpressionCompiler = expressionCompiler;
|
---|
51 | return this;
|
---|
52 | }
|
---|
53 |
|
---|
54 | /// <summary>
|
---|
55 | /// Attaches a logger, errors and log entries will be written to the logger during the parsing process.
|
---|
56 | /// </summary>
|
---|
57 | /// <param name="logger"></param>
|
---|
58 | /// <returns></returns>
|
---|
59 | public ParsingConfiguration AttachLogger(IFormulaParserLogger logger)
|
---|
60 | {
|
---|
61 | Require.That(logger).Named("logger").IsNotNull();
|
---|
62 | Logger = logger;
|
---|
63 | return this;
|
---|
64 | }
|
---|
65 |
|
---|
66 | /// <summary>
|
---|
67 | /// if a logger is attached it will be removed.
|
---|
68 | /// </summary>
|
---|
69 | /// <returns></returns>
|
---|
70 | public ParsingConfiguration DetachLogger()
|
---|
71 | {
|
---|
72 | Logger = null;
|
---|
73 | return this;
|
---|
74 | }
|
---|
75 | }
|
---|
76 | }
|
---|