alielie
2026-09-10 f3889f2d36c50cf99468594854def9b7ed069fb5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.Reflection;
 
namespace DynamicExpresso.Parsing
{
    internal class ParserSettings
    {
        private readonly Dictionary<string, Identifier> _identifiers;
        private readonly Dictionary<string, ReferenceType> _knownTypes;
        private readonly HashSet<MethodInfo> _extensionMethods;
 
        public ParserSettings(bool caseInsensitive, bool lateBindObject)
        {
            CaseInsensitive = caseInsensitive;
 
            LateBindObject = lateBindObject;
 
            KeyComparer = CaseInsensitive ? StringComparer.InvariantCultureIgnoreCase : StringComparer.InvariantCulture;
 
            KeyComparison = CaseInsensitive ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture;
 
            _identifiers = new Dictionary<string, Identifier>(KeyComparer);
 
            _knownTypes = new Dictionary<string, ReferenceType>(KeyComparer);
 
            _extensionMethods = new HashSet<MethodInfo>();
 
            AssignmentOperators = AssignmentOperators.All;
 
            DefaultNumberType = DefaultNumberType.Default;
 
            LambdaExpressions = false;
        }
 
        private ParserSettings(ParserSettings other) : this(other.CaseInsensitive, other.LateBindObject)
        {
            _knownTypes = new Dictionary<string, ReferenceType>(other._knownTypes, other._knownTypes.Comparer);
            _identifiers = new Dictionary<string, Identifier>(other._identifiers, other._identifiers.Comparer);
            _extensionMethods = new HashSet<MethodInfo>(other._extensionMethods);
 
            AssignmentOperators = other.AssignmentOperators;
            DefaultNumberType = other.DefaultNumberType;
            LambdaExpressions = other.LambdaExpressions;
        }
 
        /// <summary>
        /// Creates a deep copy of the current settings, so that the identifiers/types/methods can be changed
        /// without impacting the existing settings.
        /// </summary>
        public ParserSettings Clone()
        {
            return new ParserSettings(this);
        }
 
        public IDictionary<string, ReferenceType> KnownTypes
        {
            get { return _knownTypes; }
        }
 
        public IDictionary<string, Identifier> Identifiers
        {
            get { return _identifiers; }
        }
 
        public HashSet<MethodInfo> ExtensionMethods
        {
            get { return _extensionMethods; }
        }
 
        public bool CaseInsensitive
        {
            get;
        }
 
        public bool LateBindObject
        {
            get;
        }
 
        public StringComparison KeyComparison
        {
            get;
        }
 
        public IEqualityComparer<string> KeyComparer
        {
            get;
        }
 
        public DefaultNumberType DefaultNumberType
        {
            get;
            set;
        }
 
        public AssignmentOperators AssignmentOperators
        {
            get;
            set;
        }
 
        public bool LambdaExpressions
        {
            get;
            set;
        }
    }
}