Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WhitespaceRuleLookup.cs
Go to the documentation of this file.
4
6
7internal sealed class WhitespaceRuleLookup
8{
10 {
11 private int _priority;
12
13 private int _hashCode;
14
15 public int Priority => _priority;
16
18 {
19 }
20
21 public InternalWhitespaceRule(string localName, string namespaceName, bool preserveSpace, int priority)
22 {
24 }
25
26 public void Init(string localName, string namespaceName, bool preserveSpace, int priority)
27 {
28 Init(localName, namespaceName, preserveSpace);
30 if (localName != null && namespaceName != null)
31 {
32 _hashCode = localName.GetHashCode();
33 }
34 }
35
37 {
38 if (base.LocalName != null)
39 {
40 base.LocalName = nameTable.Add(base.LocalName);
41 }
42 if (base.NamespaceName != null)
43 {
44 base.NamespaceName = nameTable.Add(base.NamespaceName);
45 }
46 }
47
48 public override int GetHashCode()
49 {
50 return _hashCode;
51 }
52
53 public override bool Equals(object obj)
54 {
56 if (base.LocalName == internalWhitespaceRule.LocalName)
57 {
58 return base.NamespaceName == internalWhitespaceRule.NamespaceName;
59 }
60 return false;
61 }
62 }
63
64 private readonly Hashtable _qnames;
65
66 private readonly ArrayList _wildcards;
67
69
71
73 {
74 _qnames = new Hashtable();
75 _wildcards = new ArrayList();
76 }
77
79 : this()
80 {
81 for (int num = rules.Count - 1; num >= 0; num--)
82 {
85 if (whitespaceRule.LocalName == null || whitespaceRule.NamespaceName == null)
86 {
88 }
89 else
90 {
92 }
93 }
95 }
96
98 {
99 if (nameTable == _nameTable)
100 {
101 return;
102 }
105 {
106 value.Atomize(nameTable);
107 }
109 {
110 wildcard.Atomize(nameTable);
111 }
112 }
113
114 public bool ShouldStripSpace(string localName, string namespaceName)
115 {
116 _ruleTemp.Init(localName, namespaceName, preserveSpace: false, 0);
118 int count = _wildcards.Count;
119 while (count-- != 0)
120 {
122 if (internalWhitespaceRule != null)
123 {
124 if (internalWhitespaceRule.Priority > internalWhitespaceRule2.Priority)
125 {
126 return !internalWhitespaceRule.PreserveSpace;
127 }
128 if (internalWhitespaceRule.PreserveSpace == internalWhitespaceRule2.PreserveSpace)
129 {
130 continue;
131 }
132 }
133 if ((internalWhitespaceRule2.LocalName == null || (object)internalWhitespaceRule2.LocalName == localName) && (internalWhitespaceRule2.NamespaceName == null || (object)internalWhitespaceRule2.NamespaceName == namespaceName))
134 {
135 return !internalWhitespaceRule2.PreserveSpace;
136 }
137 }
138 if (internalWhitespaceRule != null)
139 {
140 return !internalWhitespaceRule.PreserveSpace;
141 }
142 return false;
143 }
144}
virtual int Add(object? value)
void Add(TKey key, TValue value)
virtual ICollection Values
Definition Hashtable.cs:534
InternalWhitespaceRule(string localName, string namespaceName, bool preserveSpace, int priority)
void Init(string localName, string namespaceName, bool preserveSpace, int priority)
bool ShouldStripSpace(string localName, string namespaceName)
WhitespaceRuleLookup(IList< WhitespaceRule > rules)