Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlQueryStaticData.cs
Go to the documentation of this file.
3using System.IO;
6
8
9internal sealed class XmlQueryStaticData
10{
12
14
15 private readonly string[] _names;
16
17 private readonly StringPair[][] _prefixMappingsList;
18
19 private readonly Int32Pair[] _filters;
20
21 private readonly XmlQueryType[] _types;
22
23 private readonly XmlCollation[] _collations;
24
25 private readonly string[] _globalNames;
26
27 private readonly EarlyBoundInfo[] _earlyBound;
28
30
32
33 public string[] Names => _names;
34
36
38
40
42
43 public string[] GlobalNames => _globalNames;
44
46
47 [RequiresUnreferencedCode("This method will create a copy that uses earlybound types which cannot be statically analyzed.")]
60
61 [RequiresUnreferencedCode("This method will create EarlyBoundInfo from passed in ebTypes array which cannot be statically analyzed.")]
62 public XmlQueryStaticData(byte[] data, Type[] ebTypes)
63 {
64 MemoryStream input = new MemoryStream(data, writable: false);
66 int num = xmlQueryDataReader.Read7BitEncodedInt();
67 if ((num & -256) > 0)
68 {
69 throw new NotSupportedException();
70 }
72 int num2 = xmlQueryDataReader.ReadInt32();
73 if (num2 != 0)
74 {
76 for (int i = 0; i < num2; i++)
77 {
79 }
80 }
81 num2 = xmlQueryDataReader.ReadInt32();
82 if (num2 != 0)
83 {
84 _names = new string[num2];
85 for (int j = 0; j < num2; j++)
86 {
87 _names[j] = xmlQueryDataReader.ReadString();
88 }
89 }
90 num2 = xmlQueryDataReader.ReadInt32();
91 if (num2 != 0)
92 {
94 for (int k = 0; k < num2; k++)
95 {
96 int num3 = xmlQueryDataReader.ReadInt32();
98 for (int l = 0; l < num3; l++)
99 {
100 _prefixMappingsList[k][l] = new StringPair(xmlQueryDataReader.ReadString(), xmlQueryDataReader.ReadString());
101 }
102 }
103 }
104 num2 = xmlQueryDataReader.ReadInt32();
105 if (num2 != 0)
106 {
107 _filters = new Int32Pair[num2];
108 for (int m = 0; m < num2; m++)
109 {
110 _filters[m] = new Int32Pair(xmlQueryDataReader.Read7BitEncodedInt(), xmlQueryDataReader.Read7BitEncodedInt());
111 }
112 }
113 num2 = xmlQueryDataReader.ReadInt32();
114 if (num2 != 0)
115 {
116 _types = new XmlQueryType[num2];
117 for (int n = 0; n < num2; n++)
118 {
120 }
121 }
122 num2 = xmlQueryDataReader.ReadInt32();
123 if (num2 != 0)
124 {
126 for (int num4 = 0; num4 < num2; num4++)
127 {
129 }
130 }
131 num2 = xmlQueryDataReader.ReadInt32();
132 if (num2 != 0)
133 {
134 _globalNames = new string[num2];
135 for (int num5 = 0; num5 < num2; num5++)
136 {
137 _globalNames[num5] = xmlQueryDataReader.ReadString();
138 }
139 }
140 num2 = xmlQueryDataReader.ReadInt32();
141 if (num2 != 0)
142 {
144 for (int num6 = 0; num6 < num2; num6++)
145 {
147 }
148 }
149 xmlQueryDataReader.Dispose();
150 }
151
152 public void GetObjectData(out byte[] data, out Type[] ebTypes)
153 {
156 xmlQueryDataWriter.Write7BitEncodedInt(0);
158 if (_whitespaceRules == null)
159 {
160 xmlQueryDataWriter.Write(0);
161 }
162 else
163 {
166 {
168 }
169 }
170 if (_names == null)
171 {
172 xmlQueryDataWriter.Write(0);
173 }
174 else
175 {
176 xmlQueryDataWriter.Write(_names.Length);
177 string[] names = _names;
178 foreach (string value in names)
179 {
181 }
182 }
183 if (_prefixMappingsList == null)
184 {
185 xmlQueryDataWriter.Write(0);
186 }
187 else
188 {
191 foreach (StringPair[] array in prefixMappingsList)
192 {
193 xmlQueryDataWriter.Write(array.Length);
195 for (int k = 0; k < array2.Length; k++)
196 {
198 xmlQueryDataWriter.Write(stringPair.Left);
199 xmlQueryDataWriter.Write(stringPair.Right);
200 }
201 }
202 }
203 if (_filters == null)
204 {
205 xmlQueryDataWriter.Write(0);
206 }
207 else
208 {
209 xmlQueryDataWriter.Write(_filters.Length);
211 for (int l = 0; l < filters.Length; l++)
212 {
214 xmlQueryDataWriter.Write7BitEncodedInt(int32Pair.Left);
215 xmlQueryDataWriter.Write7BitEncodedInt(int32Pair.Right);
216 }
217 }
218 if (_types == null)
219 {
220 xmlQueryDataWriter.Write(0);
221 }
222 else
223 {
224 xmlQueryDataWriter.Write(_types.Length);
226 foreach (XmlQueryType type in types)
227 {
229 }
230 }
231 if (_collations == null)
232 {
233 xmlQueryDataWriter.Write(0);
234 }
235 else
236 {
237 xmlQueryDataWriter.Write(_collations.Length);
240 {
242 }
243 }
244 if (_globalNames == null)
245 {
246 xmlQueryDataWriter.Write(0);
247 }
248 else
249 {
250 xmlQueryDataWriter.Write(_globalNames.Length);
251 string[] globalNames = _globalNames;
252 foreach (string value2 in globalNames)
253 {
255 }
256 }
257 if (_earlyBound == null)
258 {
259 xmlQueryDataWriter.Write(0);
260 ebTypes = null;
261 }
262 else
263 {
264 xmlQueryDataWriter.Write(_earlyBound.Length);
265 ebTypes = new Type[_earlyBound.Length];
266 int num2 = 0;
269 {
270 xmlQueryDataWriter.Write(earlyBoundInfo.NamespaceUri);
271 ebTypes[num2++] = earlyBoundInfo.EarlyBoundType;
272 }
273 }
274 xmlQueryDataWriter.Dispose();
275 data = memoryStream.ToArray();
276 }
277}
virtual void GetObjectData(SerializationInfo info, StreamingContext context)
void GetObjectData(XmlQueryDataWriter writer)
readonly XmlWriterSettings _defaultWriterSettings
void GetObjectData(out byte[] data, out Type[] ebTypes)
XmlQueryStaticData(byte[] data, Type[] ebTypes)
XmlQueryStaticData(XmlWriterSettings defaultWriterSettings, IList< WhitespaceRule > whitespaceRules, StaticDataManager staticData)
readonly IList< WhitespaceRule > _whitespaceRules
static void Serialize(BinaryWriter writer, XmlQueryType type)
static XmlQueryType Deserialize(BinaryReader reader)