Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlSerializationReader.cs
Go to the documentation of this file.
6
8
10{
11 private struct SoapArrayInfo
12 {
13 public string qname;
14
15 public int dimensions;
16
17 public int length;
18
19 public int jaggedDimensions;
20 }
21
22 protected class Fixup
23 {
25
26 private object _source;
27
28 private readonly string[] _ids;
29
31
32 public object? Source
33 {
34 get
35 {
36 return _source;
37 }
38 set
39 {
40 _source = value;
41 }
42 }
43
44 public string?[]? Ids => _ids;
45
46 public Fixup(object? o, XmlSerializationFixupCallback callback, int count)
47 : this(o, callback, new string[count])
48 {
49 }
50
51 public Fixup(object? o, XmlSerializationFixupCallback callback, string?[]? ids)
52 {
53 _callback = callback;
54 Source = o;
55 _ids = ids;
56 }
57 }
58
59 protected class CollectionFixup
60 {
62
63 private readonly object _collection;
64
65 private readonly object _collectionItems;
66
68
69 public object? Collection => _collection;
70
72
79 }
80
81 private XmlReader _r;
82
83 private XmlDocument _d;
84
86
88
90
92
94
96
98
100
102
103 private bool _soap12;
104
105 private bool _isReturnValue;
106
107 private bool _decodeName = true;
108
109 private string _schemaNsID;
110
111 private string _schemaNs1999ID;
112
113 private string _schemaNs2000ID;
114
116
117 private string _instanceNsID;
118
119 private string _instanceNs2000ID;
120
121 private string _instanceNs1999ID;
122
123 private string _soapNsID;
124
125 private string _soap12NsID;
126
127 private string _schemaID;
128
129 private string _wsdlNsID;
130
131 private string _wsdlArrayTypeID;
132
133 private string _nullID;
134
135 private string _nilID;
136
137 private string _typeID;
138
139 private string _arrayTypeID;
140
141 private string _itemTypeID;
142
143 private string _arraySizeID;
144
145 private string _arrayID;
146
147 private string _urTypeID;
148
149 private string _stringID;
150
151 private string _intID;
152
153 private string _booleanID;
154
155 private string _shortID;
156
157 private string _longID;
158
159 private string _floatID;
160
161 private string _doubleID;
162
163 private string _decimalID;
164
165 private string _dateTimeID;
166
167 private string _qnameID;
168
169 private string _dateID;
170
171 private string _timeID;
172
173 private string _hexBinaryID;
174
175 private string _base64BinaryID;
176
177 private string _base64ID;
178
179 private string _unsignedByteID;
180
181 private string _byteID;
182
183 private string _unsignedShortID;
184
185 private string _unsignedIntID;
186
187 private string _unsignedLongID;
188
189 private string _oldDecimalID;
190
191 private string _oldTimeInstantID;
192
193 private string _anyURIID;
194
195 private string _durationID;
196
197 private string _ENTITYID;
198
199 private string _ENTITIESID;
200
201 private string _gDayID;
202
203 private string _gMonthID;
204
205 private string _gMonthDayID;
206
207 private string _gYearID;
208
209 private string _gYearMonthID;
210
211 private string _IDID;
212
213 private string _IDREFID;
214
215 private string _IDREFSID;
216
217 private string _integerID;
218
219 private string _languageID;
220
221 private string _nameID;
222
223 private string _NCNameID;
224
225 private string _NMTOKENID;
226
227 private string _NMTOKENSID;
228
229 private string _negativeIntegerID;
230
231 private string _nonPositiveIntegerID;
232
233 private string _nonNegativeIntegerID;
234
235 private string _normalizedStringID;
236
237 private string _NOTATIONID;
238
239 private string _positiveIntegerID;
240
241 private string _tokenID;
242
243 private string _charID;
244
245 private string _guidID;
246
247 private string _timeSpanID;
248
249 private string _dateTimeOffsetID;
250
251 protected bool DecodeName
252 {
253 get
254 {
255 return _decodeName;
256 }
257 set
258 {
260 }
261 }
262
263 protected XmlReader Reader => _r;
264
265 protected int ReaderCount => 0;
266
268 {
269 get
270 {
271 if (_d == null)
272 {
273 _d = new XmlDocument(_r.NameTable);
275 }
276 return _d;
277 }
278 }
279
280 protected bool IsReturnValue
281 {
282 get
283 {
284 if (_isReturnValue)
285 {
286 return !_soap12;
287 }
288 return false;
289 }
290 set
291 {
293 }
294 }
295
296 protected abstract void InitIDs();
297
299 {
300 _events = events;
301 _r = r;
302 _d = null;
303 _soap12 = encodingStyle == "http://www.w3.org/2003/05/soap-encoding";
305 _schemaNsID = r.NameTable.Add("http://www.w3.org/2001/XMLSchema");
306 _schemaNs2000ID = r.NameTable.Add("http://www.w3.org/2000/10/XMLSchema");
307 _schemaNs1999ID = r.NameTable.Add("http://www.w3.org/1999/XMLSchema");
308 _schemaNonXsdTypesNsID = r.NameTable.Add("http://microsoft.com/wsdl/types/");
309 _instanceNsID = r.NameTable.Add("http://www.w3.org/2001/XMLSchema-instance");
310 _instanceNs2000ID = r.NameTable.Add("http://www.w3.org/2000/10/XMLSchema-instance");
311 _instanceNs1999ID = r.NameTable.Add("http://www.w3.org/1999/XMLSchema-instance");
312 _soapNsID = r.NameTable.Add("http://schemas.xmlsoap.org/soap/encoding/");
313 _soap12NsID = r.NameTable.Add("http://www.w3.org/2003/05/soap-encoding");
314 _schemaID = r.NameTable.Add("schema");
315 _wsdlNsID = r.NameTable.Add("http://schemas.xmlsoap.org/wsdl/");
316 _wsdlArrayTypeID = r.NameTable.Add("arrayType");
317 _nullID = r.NameTable.Add("null");
318 _nilID = r.NameTable.Add("nil");
319 _typeID = r.NameTable.Add("type");
320 _arrayTypeID = r.NameTable.Add("arrayType");
321 _itemTypeID = r.NameTable.Add("itemType");
322 _arraySizeID = r.NameTable.Add("arraySize");
323 _arrayID = r.NameTable.Add("Array");
324 _urTypeID = r.NameTable.Add("anyType");
325 InitIDs();
326 }
327
329 {
331 }
332
333 private void InitPrimitiveIDs()
334 {
335 if (_tokenID == null)
336 {
337 _r.NameTable.Add("http://www.w3.org/2001/XMLSchema");
338 _r.NameTable.Add("http://microsoft.com/wsdl/types/");
339 _stringID = _r.NameTable.Add("string");
340 _intID = _r.NameTable.Add("int");
341 _booleanID = _r.NameTable.Add("boolean");
342 _shortID = _r.NameTable.Add("short");
343 _longID = _r.NameTable.Add("long");
344 _floatID = _r.NameTable.Add("float");
345 _doubleID = _r.NameTable.Add("double");
346 _decimalID = _r.NameTable.Add("decimal");
347 _dateTimeID = _r.NameTable.Add("dateTime");
348 _qnameID = _r.NameTable.Add("QName");
349 _dateID = _r.NameTable.Add("date");
350 _timeID = _r.NameTable.Add("time");
351 _hexBinaryID = _r.NameTable.Add("hexBinary");
352 _base64BinaryID = _r.NameTable.Add("base64Binary");
353 _unsignedByteID = _r.NameTable.Add("unsignedByte");
354 _byteID = _r.NameTable.Add("byte");
355 _unsignedShortID = _r.NameTable.Add("unsignedShort");
356 _unsignedIntID = _r.NameTable.Add("unsignedInt");
357 _unsignedLongID = _r.NameTable.Add("unsignedLong");
358 _oldDecimalID = _r.NameTable.Add("decimal");
359 _oldTimeInstantID = _r.NameTable.Add("timeInstant");
360 _charID = _r.NameTable.Add("char");
361 _guidID = _r.NameTable.Add("guid");
362 _timeSpanID = _r.NameTable.Add("TimeSpan");
363 _dateTimeOffsetID = _r.NameTable.Add("dateTimeOffset");
364 _base64ID = _r.NameTable.Add("base64");
365 _anyURIID = _r.NameTable.Add("anyURI");
366 _durationID = _r.NameTable.Add("duration");
367 _ENTITYID = _r.NameTable.Add("ENTITY");
368 _ENTITIESID = _r.NameTable.Add("ENTITIES");
369 _gDayID = _r.NameTable.Add("gDay");
370 _gMonthID = _r.NameTable.Add("gMonth");
371 _gMonthDayID = _r.NameTable.Add("gMonthDay");
372 _gYearID = _r.NameTable.Add("gYear");
373 _gYearMonthID = _r.NameTable.Add("gYearMonth");
374 _IDID = _r.NameTable.Add("ID");
375 _IDREFID = _r.NameTable.Add("IDREF");
376 _IDREFSID = _r.NameTable.Add("IDREFS");
377 _integerID = _r.NameTable.Add("integer");
378 _languageID = _r.NameTable.Add("language");
379 _nameID = _r.NameTable.Add("Name");
380 _NCNameID = _r.NameTable.Add("NCName");
381 _NMTOKENID = _r.NameTable.Add("NMTOKEN");
382 _NMTOKENSID = _r.NameTable.Add("NMTOKENS");
383 _negativeIntegerID = _r.NameTable.Add("negativeInteger");
384 _nonNegativeIntegerID = _r.NameTable.Add("nonNegativeInteger");
385 _nonPositiveIntegerID = _r.NameTable.Add("nonPositiveInteger");
386 _normalizedStringID = _r.NameTable.Add("normalizedString");
387 _NOTATIONID = _r.NameTable.Add("NOTATION");
388 _positiveIntegerID = _r.NameTable.Add("positiveInteger");
389 _tokenID = _r.NameTable.Add("token");
390 }
391 }
392
394 {
396 if (attribute == null)
397 {
399 if (attribute == null)
400 {
402 if (attribute == null)
403 {
404 return null;
405 }
406 }
407 }
409 }
410
412 {
414 if ((object)typeName.Namespace == _schemaNsID || (object)typeName.Namespace == _soapNsID || (object)typeName.Namespace == _soap12NsID)
415 {
416 if ((object)typeName.Name == _stringID || (object)typeName.Name == _anyURIID || (object)typeName.Name == _durationID || (object)typeName.Name == _ENTITYID || (object)typeName.Name == _ENTITIESID || (object)typeName.Name == _gDayID || (object)typeName.Name == _gMonthID || (object)typeName.Name == _gMonthDayID || (object)typeName.Name == _gYearID || (object)typeName.Name == _gYearMonthID || (object)typeName.Name == _IDID || (object)typeName.Name == _IDREFID || (object)typeName.Name == _IDREFSID || (object)typeName.Name == _integerID || (object)typeName.Name == _languageID || (object)typeName.Name == _nameID || (object)typeName.Name == _NCNameID || (object)typeName.Name == _NMTOKENID || (object)typeName.Name == _NMTOKENSID || (object)typeName.Name == _negativeIntegerID || (object)typeName.Name == _nonPositiveIntegerID || (object)typeName.Name == _nonNegativeIntegerID || (object)typeName.Name == _normalizedStringID || (object)typeName.Name == _NOTATIONID || (object)typeName.Name == _positiveIntegerID || (object)typeName.Name == _tokenID)
417 {
418 return typeof(string);
419 }
420 if ((object)typeName.Name == _intID)
421 {
422 return typeof(int);
423 }
424 if ((object)typeName.Name == _booleanID)
425 {
426 return typeof(bool);
427 }
428 if ((object)typeName.Name == _shortID)
429 {
430 return typeof(short);
431 }
432 if ((object)typeName.Name == _longID)
433 {
434 return typeof(long);
435 }
436 if ((object)typeName.Name == _floatID)
437 {
438 return typeof(float);
439 }
440 if ((object)typeName.Name == _doubleID)
441 {
442 return typeof(double);
443 }
444 if ((object)typeName.Name == _decimalID)
445 {
446 return typeof(decimal);
447 }
448 if ((object)typeName.Name == _dateTimeID)
449 {
450 return typeof(DateTime);
451 }
452 if ((object)typeName.Name == _qnameID)
453 {
454 return typeof(XmlQualifiedName);
455 }
456 if ((object)typeName.Name == _dateID)
457 {
458 return typeof(DateTime);
459 }
460 if ((object)typeName.Name == _timeID)
461 {
462 return typeof(DateTime);
463 }
464 if ((object)typeName.Name == _hexBinaryID)
465 {
466 return typeof(byte[]);
467 }
468 if ((object)typeName.Name == _base64BinaryID)
469 {
470 return typeof(byte[]);
471 }
472 if ((object)typeName.Name == _unsignedByteID)
473 {
474 return typeof(byte);
475 }
476 if ((object)typeName.Name == _byteID)
477 {
478 return typeof(sbyte);
479 }
480 if ((object)typeName.Name == _unsignedShortID)
481 {
482 return typeof(ushort);
483 }
484 if ((object)typeName.Name == _unsignedIntID)
485 {
486 return typeof(uint);
487 }
488 if ((object)typeName.Name == _unsignedLongID)
489 {
490 return typeof(ulong);
491 }
492 throw CreateUnknownTypeException(typeName);
493 }
494 if ((object)typeName.Namespace == _schemaNs2000ID || (object)typeName.Namespace == _schemaNs1999ID)
495 {
496 if ((object)typeName.Name == _stringID || (object)typeName.Name == _anyURIID || (object)typeName.Name == _durationID || (object)typeName.Name == _ENTITYID || (object)typeName.Name == _ENTITIESID || (object)typeName.Name == _gDayID || (object)typeName.Name == _gMonthID || (object)typeName.Name == _gMonthDayID || (object)typeName.Name == _gYearID || (object)typeName.Name == _gYearMonthID || (object)typeName.Name == _IDID || (object)typeName.Name == _IDREFID || (object)typeName.Name == _IDREFSID || (object)typeName.Name == _integerID || (object)typeName.Name == _languageID || (object)typeName.Name == _nameID || (object)typeName.Name == _NCNameID || (object)typeName.Name == _NMTOKENID || (object)typeName.Name == _NMTOKENSID || (object)typeName.Name == _negativeIntegerID || (object)typeName.Name == _nonPositiveIntegerID || (object)typeName.Name == _nonNegativeIntegerID || (object)typeName.Name == _normalizedStringID || (object)typeName.Name == _NOTATIONID || (object)typeName.Name == _positiveIntegerID || (object)typeName.Name == _tokenID)
497 {
498 return typeof(string);
499 }
500 if ((object)typeName.Name == _intID)
501 {
502 return typeof(int);
503 }
504 if ((object)typeName.Name == _booleanID)
505 {
506 return typeof(bool);
507 }
508 if ((object)typeName.Name == _shortID)
509 {
510 return typeof(short);
511 }
512 if ((object)typeName.Name == _longID)
513 {
514 return typeof(long);
515 }
516 if ((object)typeName.Name == _floatID)
517 {
518 return typeof(float);
519 }
520 if ((object)typeName.Name == _doubleID)
521 {
522 return typeof(double);
523 }
524 if ((object)typeName.Name == _oldDecimalID)
525 {
526 return typeof(decimal);
527 }
528 if ((object)typeName.Name == _oldTimeInstantID)
529 {
530 return typeof(DateTime);
531 }
532 if ((object)typeName.Name == _qnameID)
533 {
534 return typeof(XmlQualifiedName);
535 }
536 if ((object)typeName.Name == _dateID)
537 {
538 return typeof(DateTime);
539 }
540 if ((object)typeName.Name == _timeID)
541 {
542 return typeof(DateTime);
543 }
544 if ((object)typeName.Name == _hexBinaryID)
545 {
546 return typeof(byte[]);
547 }
548 if ((object)typeName.Name == _byteID)
549 {
550 return typeof(sbyte);
551 }
552 if ((object)typeName.Name == _unsignedShortID)
553 {
554 return typeof(ushort);
555 }
556 if ((object)typeName.Name == _unsignedIntID)
557 {
558 return typeof(uint);
559 }
560 if ((object)typeName.Name == _unsignedLongID)
561 {
562 return typeof(ulong);
563 }
564 throw CreateUnknownTypeException(typeName);
565 }
566 if ((object)typeName.Namespace == _schemaNonXsdTypesNsID)
567 {
568 if ((object)typeName.Name == _charID)
569 {
570 return typeof(char);
571 }
572 if ((object)typeName.Name == _guidID)
573 {
574 return typeof(Guid);
575 }
576 throw CreateUnknownTypeException(typeName);
577 }
578 if (throwOnUnknown)
579 {
580 throw CreateUnknownTypeException(typeName);
581 }
582 return null;
583 }
584
585 private bool IsPrimitiveNamespace(string ns)
586 {
587 if ((object)ns != _schemaNsID && (object)ns != _schemaNonXsdTypesNsID && (object)ns != _soapNsID && (object)ns != _soap12NsID && (object)ns != _schemaNs2000ID)
588 {
589 return (object)ns == _schemaNs1999ID;
590 }
591 return true;
592 }
593
594 private string ReadStringValue()
595 {
596 if (_r.IsEmptyElement)
597 {
598 _r.Skip();
599 return string.Empty;
600 }
602 string result = _r.ReadString();
604 return result;
605 }
606
608 {
609 bool flag = false;
610 string value;
611 if (_r.IsEmptyElement)
612 {
613 value = string.Empty;
614 flag = true;
615 }
616 else
617 {
619 value = _r.ReadString();
620 }
622 if (flag)
623 {
624 _r.Skip();
625 }
626 else
627 {
629 }
630 return result;
631 }
632
633 private byte[] ReadByteArray(bool isBase64)
634 {
636 int num = 1024;
637 int num2 = -1;
638 int num3 = 0;
639 int num4 = 0;
640 byte[] array = new byte[num];
642 while (num2 != 0)
643 {
644 if (num3 == array.Length)
645 {
646 num = Math.Min(num * 2, 65536);
647 array = new byte[num];
648 num3 = 0;
650 }
652 num3 += num2;
653 num4 += num2;
654 }
655 byte[] array2 = new byte[num4];
656 num3 = 0;
657 foreach (byte[] item in arrayList)
658 {
659 num = Math.Min(item.Length, num4);
660 if (num > 0)
661 {
662 Buffer.BlockCopy(item, 0, array2, num3, num);
663 num3 += num;
664 num4 -= num;
665 }
666 }
668 return array2;
669 }
670
672 {
674 }
675
677 {
679 object obj = null;
680 if (!IsPrimitiveNamespace(type.Namespace) || (object)type.Name == _urTypeID)
681 {
683 }
684 if ((object)type.Namespace == _schemaNsID || (object)type.Namespace == _soapNsID || (object)type.Namespace == _soap12NsID)
685 {
686 if ((object)type.Name == _stringID || (object)type.Name == _normalizedStringID)
687 {
688 return ReadStringValue();
689 }
690 if ((object)type.Name == _anyURIID || (object)type.Name == _durationID || (object)type.Name == _ENTITYID || (object)type.Name == _ENTITIESID || (object)type.Name == _gDayID || (object)type.Name == _gMonthID || (object)type.Name == _gMonthDayID || (object)type.Name == _gYearID || (object)type.Name == _gYearMonthID || (object)type.Name == _IDID || (object)type.Name == _IDREFID || (object)type.Name == _IDREFSID || (object)type.Name == _integerID || (object)type.Name == _languageID || (object)type.Name == _nameID || (object)type.Name == _NCNameID || (object)type.Name == _NMTOKENID || (object)type.Name == _NMTOKENSID || (object)type.Name == _negativeIntegerID || (object)type.Name == _nonPositiveIntegerID || (object)type.Name == _nonNegativeIntegerID || (object)type.Name == _NOTATIONID || (object)type.Name == _positiveIntegerID || (object)type.Name == _tokenID)
691 {
693 }
694 if ((object)type.Name == _intID)
695 {
697 }
698 if ((object)type.Name == _booleanID)
699 {
701 }
702 if ((object)type.Name == _shortID)
703 {
705 }
706 if ((object)type.Name == _longID)
707 {
709 }
710 if ((object)type.Name == _floatID)
711 {
713 }
714 if ((object)type.Name == _doubleID)
715 {
717 }
718 if ((object)type.Name == _decimalID)
719 {
721 }
722 if ((object)type.Name == _dateTimeID)
723 {
724 return ToDateTime(ReadStringValue());
725 }
726 if ((object)type.Name == _qnameID)
727 {
728 return ReadXmlQualifiedName();
729 }
730 if ((object)type.Name == _dateID)
731 {
732 return ToDate(ReadStringValue());
733 }
734 if ((object)type.Name == _timeID)
735 {
736 return ToTime(ReadStringValue());
737 }
738 if ((object)type.Name == _unsignedByteID)
739 {
741 }
742 if ((object)type.Name == _byteID)
743 {
745 }
746 if ((object)type.Name == _unsignedShortID)
747 {
749 }
750 if ((object)type.Name == _unsignedIntID)
751 {
753 }
754 if ((object)type.Name == _unsignedLongID)
755 {
757 }
758 if ((object)type.Name == _hexBinaryID)
759 {
760 return ToByteArrayHex(isNull: false);
761 }
762 if ((object)type.Name == _base64BinaryID)
763 {
764 return ToByteArrayBase64(isNull: false);
765 }
766 if ((object)type.Name == _base64ID && ((object)type.Namespace == _soapNsID || (object)type.Namespace == _soap12NsID))
767 {
768 return ToByteArrayBase64(isNull: false);
769 }
771 }
772 if ((object)type.Namespace == _schemaNs2000ID || (object)type.Namespace == _schemaNs1999ID)
773 {
774 if ((object)type.Name == _stringID || (object)type.Name == _normalizedStringID)
775 {
776 return ReadStringValue();
777 }
778 if ((object)type.Name == _anyURIID || (object)type.Name == _anyURIID || (object)type.Name == _durationID || (object)type.Name == _ENTITYID || (object)type.Name == _ENTITIESID || (object)type.Name == _gDayID || (object)type.Name == _gMonthID || (object)type.Name == _gMonthDayID || (object)type.Name == _gYearID || (object)type.Name == _gYearMonthID || (object)type.Name == _IDID || (object)type.Name == _IDREFID || (object)type.Name == _IDREFSID || (object)type.Name == _integerID || (object)type.Name == _languageID || (object)type.Name == _nameID || (object)type.Name == _NCNameID || (object)type.Name == _NMTOKENID || (object)type.Name == _NMTOKENSID || (object)type.Name == _negativeIntegerID || (object)type.Name == _nonPositiveIntegerID || (object)type.Name == _nonNegativeIntegerID || (object)type.Name == _NOTATIONID || (object)type.Name == _positiveIntegerID || (object)type.Name == _tokenID)
779 {
781 }
782 if ((object)type.Name == _intID)
783 {
785 }
786 if ((object)type.Name == _booleanID)
787 {
789 }
790 if ((object)type.Name == _shortID)
791 {
793 }
794 if ((object)type.Name == _longID)
795 {
797 }
798 if ((object)type.Name == _floatID)
799 {
801 }
802 if ((object)type.Name == _doubleID)
803 {
805 }
806 if ((object)type.Name == _oldDecimalID)
807 {
809 }
810 if ((object)type.Name == _oldTimeInstantID)
811 {
812 return ToDateTime(ReadStringValue());
813 }
814 if ((object)type.Name == _qnameID)
815 {
816 return ReadXmlQualifiedName();
817 }
818 if ((object)type.Name == _dateID)
819 {
820 return ToDate(ReadStringValue());
821 }
822 if ((object)type.Name == _timeID)
823 {
824 return ToTime(ReadStringValue());
825 }
826 if ((object)type.Name == _unsignedByteID)
827 {
829 }
830 if ((object)type.Name == _byteID)
831 {
833 }
834 if ((object)type.Name == _unsignedShortID)
835 {
837 }
838 if ((object)type.Name == _unsignedIntID)
839 {
841 }
842 if ((object)type.Name == _unsignedLongID)
843 {
845 }
847 }
848 if ((object)type.Namespace == _schemaNonXsdTypesNsID)
849 {
850 if ((object)type.Name == _charID)
851 {
852 return ToChar(ReadStringValue());
853 }
854 if ((object)type.Name == _guidID)
855 {
857 }
858 if ((object)type.Name == _timeSpanID)
859 {
861 }
862 if ((object)type.Name == _dateTimeOffsetID)
863 {
865 }
867 }
869 }
870
872 {
874 object obj = null;
875 if (!IsPrimitiveNamespace(type.Namespace) || (object)type.Name == _urTypeID)
876 {
877 return null;
878 }
879 if ((object)type.Namespace == _schemaNsID || (object)type.Namespace == _soapNsID || (object)type.Namespace == _soap12NsID)
880 {
881 if ((object)type.Name == _stringID || (object)type.Name == _anyURIID || (object)type.Name == _durationID || (object)type.Name == _ENTITYID || (object)type.Name == _ENTITIESID || (object)type.Name == _gDayID || (object)type.Name == _gMonthID || (object)type.Name == _gMonthDayID || (object)type.Name == _gYearID || (object)type.Name == _gYearMonthID || (object)type.Name == _IDID || (object)type.Name == _IDREFID || (object)type.Name == _IDREFSID || (object)type.Name == _integerID || (object)type.Name == _languageID || (object)type.Name == _nameID || (object)type.Name == _NCNameID || (object)type.Name == _NMTOKENID || (object)type.Name == _NMTOKENSID || (object)type.Name == _negativeIntegerID || (object)type.Name == _nonPositiveIntegerID || (object)type.Name == _nonNegativeIntegerID || (object)type.Name == _normalizedStringID || (object)type.Name == _NOTATIONID || (object)type.Name == _positiveIntegerID || (object)type.Name == _tokenID)
882 {
883 return null;
884 }
885 if ((object)type.Name == _intID)
886 {
887 return null;
888 }
889 if ((object)type.Name == _booleanID)
890 {
891 return null;
892 }
893 if ((object)type.Name == _shortID)
894 {
895 return null;
896 }
897 if ((object)type.Name == _longID)
898 {
899 return null;
900 }
901 if ((object)type.Name == _floatID)
902 {
903 return null;
904 }
905 if ((object)type.Name == _doubleID)
906 {
907 return null;
908 }
909 if ((object)type.Name == _decimalID)
910 {
911 return null;
912 }
913 if ((object)type.Name == _dateTimeID)
914 {
915 return null;
916 }
917 if ((object)type.Name == _qnameID)
918 {
919 return null;
920 }
921 if ((object)type.Name == _dateID)
922 {
923 return null;
924 }
925 if ((object)type.Name == _timeID)
926 {
927 return null;
928 }
929 if ((object)type.Name == _unsignedByteID)
930 {
931 return null;
932 }
933 if ((object)type.Name == _byteID)
934 {
935 return null;
936 }
937 if ((object)type.Name == _unsignedShortID)
938 {
939 return null;
940 }
941 if ((object)type.Name == _unsignedIntID)
942 {
943 return null;
944 }
945 if ((object)type.Name == _unsignedLongID)
946 {
947 return null;
948 }
949 if ((object)type.Name == _hexBinaryID)
950 {
951 return null;
952 }
953 if ((object)type.Name == _base64BinaryID)
954 {
955 return null;
956 }
957 if ((object)type.Name == _base64ID && ((object)type.Namespace == _soapNsID || (object)type.Namespace == _soap12NsID))
958 {
959 return null;
960 }
961 return null;
962 }
963 if ((object)type.Namespace == _schemaNonXsdTypesNsID)
964 {
965 if ((object)type.Name == _charID)
966 {
967 return null;
968 }
969 if ((object)type.Name == _guidID)
970 {
971 return null;
972 }
973 if ((object)type.Name == _timeSpanID)
974 {
975 return null;
976 }
977 if ((object)type.Name == _dateTimeOffsetID)
978 {
979 return null;
980 }
981 return null;
982 }
983 return null;
984 }
985
986 protected bool IsXmlnsAttribute(string name)
987 {
988 if (!name.StartsWith("xmlns", StringComparison.Ordinal))
989 {
990 return false;
991 }
992 if (name.Length == 5)
993 {
994 return true;
995 }
996 return name[5] == ':';
997 }
998
1000 {
1001 if ((object)attr.LocalName == _wsdlArrayTypeID && (object)attr.NamespaceURI == _wsdlNsID)
1002 {
1003 int num = attr.Value.LastIndexOf(':');
1004 if (num < 0)
1005 {
1006 attr.Value = _r.LookupNamespace("") + ":" + attr.Value;
1007 }
1008 else
1009 {
1010 attr.Value = _r.LookupNamespace(attr.Value.Substring(0, num)) + ":" + attr.Value.AsSpan(num + 1);
1011 }
1012 }
1013 }
1014
1015 protected bool ReadNull()
1016 {
1017 if (!GetNullAttr())
1018 {
1019 return false;
1020 }
1021 if (_r.IsEmptyElement)
1022 {
1023 _r.Skip();
1024 return true;
1025 }
1027 while (_r.NodeType != XmlNodeType.EndElement)
1028 {
1029 UnknownNode(null);
1030 }
1032 return true;
1033 }
1034
1035 protected bool GetNullAttr()
1036 {
1038 if (attribute == null)
1039 {
1041 }
1042 if (attribute == null)
1043 {
1045 if (attribute == null)
1046 {
1048 }
1049 }
1050 if (attribute == null || !XmlConvert.ToBoolean(attribute))
1051 {
1052 return false;
1053 }
1054 return true;
1055 }
1056
1057 protected string? ReadNullableString()
1058 {
1059 if (ReadNull())
1060 {
1061 return null;
1062 }
1063 return _r.ReadElementString();
1064 }
1065
1067 {
1068 if (ReadNull())
1069 {
1070 return null;
1071 }
1072 return ReadElementQualifiedName();
1073 }
1074
1076 {
1077 if (_r.IsEmptyElement)
1078 {
1079 XmlQualifiedName result = new XmlQualifiedName(string.Empty, _r.LookupNamespace(""));
1080 _r.Skip();
1081 return result;
1082 }
1085 return result2;
1086 }
1087
1089 {
1091 if (xmlNode == null)
1092 {
1093 return null;
1094 }
1096 xmlDocument.AppendChild(xmlDocument.ImportNode(xmlNode, deep: true));
1097 return xmlDocument;
1098 }
1099
1100 [return: NotNullIfNotNull("value")]
1101 protected string? CollapseWhitespace(string? value)
1102 {
1103 return value?.Trim();
1104 }
1105
1106 protected XmlNode? ReadXmlNode(bool wrapped)
1107 {
1108 XmlNode result = null;
1109 if (wrapped)
1110 {
1111 if (ReadNull())
1112 {
1113 return null;
1114 }
1116 _r.MoveToContent();
1117 if (_r.NodeType != XmlNodeType.EndElement)
1118 {
1119 result = Document.ReadNode(_r);
1120 }
1121 while (_r.NodeType != XmlNodeType.EndElement)
1122 {
1123 UnknownNode(null);
1124 }
1126 }
1127 else
1128 {
1129 result = Document.ReadNode(_r);
1130 }
1131 return result;
1132 }
1133
1134 [return: NotNullIfNotNull("value")]
1135 protected static byte[]? ToByteArrayBase64(string? value)
1136 {
1138 }
1139
1140 protected byte[]? ToByteArrayBase64(bool isNull)
1141 {
1142 if (isNull)
1143 {
1144 return null;
1145 }
1146 return ReadByteArray(isBase64: true);
1147 }
1148
1149 [return: NotNullIfNotNull("value")]
1150 protected static byte[]? ToByteArrayHex(string? value)
1151 {
1153 }
1154
1155 protected byte[]? ToByteArrayHex(bool isNull)
1156 {
1157 if (isNull)
1158 {
1159 return null;
1160 }
1161 return ReadByteArray(isBase64: false);
1162 }
1163
1164 protected int GetArrayLength(string name, string ns)
1165 {
1166 if (GetNullAttr())
1167 {
1168 return 0;
1169 }
1172 if (soapArrayInfo.dimensions != 1)
1173 {
1175 }
1177 if (xmlQualifiedName.Name != name)
1178 {
1180 }
1181 if (xmlQualifiedName.Namespace != ns)
1182 {
1184 }
1185 return soapArrayInfo.length;
1186 }
1187
1189 {
1190 if (value == null)
1191 {
1193 }
1194 if (value.Length == 0)
1195 {
1197 }
1198 char[] array = value.ToCharArray();
1199 int num = array.Length;
1200 SoapArrayInfo result = default(SoapArrayInfo);
1201 int num2 = num - 1;
1202 if (array[num2] != ']')
1203 {
1205 }
1206 num2--;
1207 while (num2 != -1 && array[num2] != '[')
1208 {
1209 if (array[num2] == ',')
1210 {
1212 }
1213 num2--;
1214 }
1215 if (num2 == -1)
1216 {
1218 }
1219 int num3 = num - num2 - 2;
1220 if (num3 > 0)
1221 {
1222 string text = new string(array, num2 + 1, num3);
1223 try
1224 {
1226 }
1227 catch (Exception ex)
1228 {
1230 {
1231 throw;
1232 }
1234 }
1235 }
1236 else
1237 {
1238 result.length = -1;
1239 }
1240 num2--;
1242 while (num2 != -1 && array[num2] == ']')
1243 {
1244 num2--;
1245 if (num2 < 0)
1246 {
1248 }
1249 if (array[num2] == ',')
1250 {
1252 }
1253 if (array[num2] != '[')
1254 {
1256 }
1257 num2--;
1258 result.jaggedDimensions++;
1259 }
1261 result.qname = new string(array, 0, num2 + 1);
1262 return result;
1263 }
1264
1266 {
1267 SoapArrayInfo result = default(SoapArrayInfo);
1268 if (itemType != null && itemType.Length > 0)
1269 {
1271 }
1272 else
1273 {
1274 result.qname = "";
1275 }
1276 string[] array = ((arraySize == null || arraySize.Length <= 0) ? Array.Empty<string>() : arraySize.Split((char[]?)null));
1278 result.length = -1;
1279 for (int i = 0; i < array.Length; i++)
1280 {
1281 if (array[i].Length <= 0)
1282 {
1283 continue;
1284 }
1285 if (array[i] == "*")
1286 {
1287 result.dimensions++;
1288 continue;
1289 }
1290 try
1291 {
1293 result.dimensions++;
1294 }
1295 catch (Exception ex)
1296 {
1298 {
1299 throw;
1300 }
1302 }
1303 }
1304 if (result.dimensions == 0)
1305 {
1307 }
1308 return result;
1309 }
1310
1311 protected static DateTime ToDateTime(string value)
1312 {
1314 }
1315
1316 protected static DateTime ToDate(string value)
1317 {
1319 }
1320
1321 protected static DateTime ToTime(string value)
1322 {
1324 }
1325
1326 protected static char ToChar(string value)
1327 {
1329 }
1330
1331 protected static long ToEnum(string value, Hashtable h, string typeName)
1332 {
1333 return XmlCustomFormatter.ToEnum(value, h, typeName, validate: true);
1334 }
1335
1336 [return: NotNullIfNotNull("value")]
1337 protected static string? ToXmlName(string? value)
1338 {
1340 }
1341
1342 [return: NotNullIfNotNull("value")]
1343 protected static string? ToXmlNCName(string? value)
1344 {
1346 }
1347
1348 [return: NotNullIfNotNull("value")]
1349 protected static string? ToXmlNmToken(string? value)
1350 {
1352 }
1353
1354 [return: NotNullIfNotNull("value")]
1355 protected static string? ToXmlNmTokens(string? value)
1356 {
1358 }
1359
1361 {
1363 }
1364
1366 {
1367 int num = value?.LastIndexOf(':') ?? (-1);
1368 string text = ((num < 0) ? null : value.Substring(0, num));
1369 string text2 = value.Substring(num + 1);
1370 if (decodeName)
1371 {
1374 }
1375 if (text == null || text.Length == 0)
1376 {
1377 return new XmlQualifiedName(_r.NameTable.Add(value), _r.LookupNamespace(string.Empty));
1378 }
1379 string text3 = _r.LookupNamespace(text);
1380 if (text3 == null)
1381 {
1383 }
1385 }
1386
1387 protected void UnknownAttribute(object? o, XmlAttribute attr)
1388 {
1389 UnknownAttribute(o, attr, null);
1390 }
1391
1392 protected void UnknownAttribute(object? o, XmlAttribute attr, string? qnames)
1393 {
1394 if (_events.OnUnknownAttribute != null)
1395 {
1396 GetCurrentPosition(out var lineNumber, out var linePosition);
1397 XmlAttributeEventArgs e = new XmlAttributeEventArgs(attr, lineNumber, linePosition, o, qnames);
1399 }
1400 }
1401
1402 protected void UnknownElement(object? o, XmlElement elem)
1403 {
1404 UnknownElement(o, elem, null);
1405 }
1406
1407 protected void UnknownElement(object? o, XmlElement elem, string? qnames)
1408 {
1409 if (_events.OnUnknownElement != null)
1410 {
1411 GetCurrentPosition(out var lineNumber, out var linePosition);
1412 XmlElementEventArgs e = new XmlElementEventArgs(elem, lineNumber, linePosition, o, qnames);
1414 }
1415 }
1416
1417 protected void UnknownNode(object? o)
1418 {
1419 UnknownNode(o, null);
1420 }
1421
1422 protected void UnknownNode(object? o, string? qnames)
1423 {
1424 if (_r.NodeType == XmlNodeType.None || _r.NodeType == XmlNodeType.Whitespace)
1425 {
1426 _r.Read();
1427 }
1428 else
1429 {
1430 if (_r.NodeType == XmlNodeType.EndElement)
1431 {
1432 return;
1433 }
1434 if (_events.OnUnknownNode != null)
1435 {
1437 }
1438 else if (_r.NodeType != XmlNodeType.Attribute || _events.OnUnknownAttribute != null)
1439 {
1440 if (_r.NodeType == XmlNodeType.Element && _events.OnUnknownElement == null)
1441 {
1442 _r.Skip();
1443 }
1444 else
1445 {
1447 }
1448 }
1449 }
1450 }
1451
1452 private void UnknownNode(XmlNode unknownNode, object o, string qnames)
1453 {
1454 if (unknownNode != null)
1455 {
1456 if (unknownNode.NodeType != 0 && unknownNode.NodeType != XmlNodeType.Whitespace && _events.OnUnknownNode != null)
1457 {
1458 GetCurrentPosition(out var lineNumber, out var linePosition);
1459 XmlNodeEventArgs e = new XmlNodeEventArgs(unknownNode, lineNumber, linePosition, o);
1461 }
1462 if (unknownNode.NodeType == XmlNodeType.Attribute)
1463 {
1465 }
1466 else if (unknownNode.NodeType == XmlNodeType.Element)
1467 {
1469 }
1470 }
1471 }
1472
1473 private void GetCurrentPosition(out int lineNumber, out int linePosition)
1474 {
1475 if (Reader is IXmlLineInfo)
1476 {
1478 lineNumber = xmlLineInfo.LineNumber;
1479 linePosition = xmlLineInfo.LinePosition;
1480 }
1481 else
1482 {
1483 lineNumber = (linePosition = -1);
1484 }
1485 }
1486
1487 protected void UnreferencedObject(string? id, object? o)
1488 {
1489 if (_events.OnUnreferencedObject != null)
1490 {
1493 }
1494 }
1495
1496 private string CurrentTag()
1497 {
1498 return _r.NodeType switch
1499 {
1500 XmlNodeType.Element => "<" + _r.LocalName + " xmlns='" + _r.NamespaceURI + "'>",
1501 XmlNodeType.EndElement => ">",
1503 XmlNodeType.CDATA => "CDATA",
1504 XmlNodeType.Comment => "<--",
1506 _ => "(unknown)",
1507 };
1508 }
1509
1514
1519
1520 protected Exception CreateAbstractTypeException(string name, string? ns)
1521 {
1523 }
1524
1529
1534
1539
1544
1546 {
1547 return CreateInvalidCastException(type, value, null);
1548 }
1549
1550 protected Exception CreateInvalidCastException(Type type, object? value, string? id)
1551 {
1552 if (value == null)
1553 {
1555 }
1556 if (id == null)
1557 {
1558 return new InvalidCastException(System.SR.Format(System.SR.XmlInvalidCast, value.GetType().FullName, type.FullName));
1559 }
1560 return new InvalidCastException(System.SR.Format(System.SR.XmlInvalidCastWithId, value.GetType().FullName, type.FullName, id));
1561 }
1562
1567
1568 protected Exception CreateMissingIXmlSerializableType(string? name, string? ns, string? clrType)
1569 {
1570 return new InvalidOperationException(System.SR.Format(System.SR.XmlSerializableMissingClrType, name, ns, "XmlIncludeAttribute", clrType));
1571 }
1572
1574 {
1575 if (a == null)
1576 {
1577 return Array.CreateInstance(elementType, 32);
1578 }
1579 if (index < a.Length)
1580 {
1581 return a;
1582 }
1584 Array.Copy(a, array, index);
1585 return array;
1586 }
1587
1589 {
1590 if (a == null)
1591 {
1592 if (isNullable)
1593 {
1594 return null;
1595 }
1596 return Array.CreateInstance(elementType, 0);
1597 }
1598 if (a.Length == length)
1599 {
1600 return a;
1601 }
1603 Array.Copy(a, array, length);
1604 return array;
1605 }
1606
1607 [return: NotNullIfNotNull("value")]
1608 protected string? ReadString(string? value)
1609 {
1610 return ReadString(value, trim: false);
1611 }
1612
1613 [return: NotNullIfNotNull("value")]
1614 protected string? ReadString(string? value, bool trim)
1615 {
1616 string text = _r.ReadString();
1617 if (text != null && trim)
1618 {
1619 text = text.Trim();
1620 }
1621 if (value == null || value.Length == 0)
1622 {
1623 return text;
1624 }
1625 return value + text;
1626 }
1627
1632
1634 {
1635 string text = null;
1636 string text2 = null;
1637 if (wrappedAny)
1638 {
1639 text = _r.LocalName;
1641 _r.Read();
1642 _r.MoveToContent();
1643 }
1644 serializable.ReadXml(_r);
1645 if (wrappedAny)
1646 {
1647 while (_r.NodeType == XmlNodeType.Whitespace)
1648 {
1649 _r.Skip();
1650 }
1651 if (_r.NodeType == XmlNodeType.None)
1652 {
1653 _r.Skip();
1654 }
1655 if (_r.NodeType == XmlNodeType.EndElement && _r.LocalName == text && _r.NamespaceURI == text2)
1656 {
1657 Reader.Read();
1658 }
1659 }
1660 return serializable;
1661 }
1662
1663 protected bool ReadReference([NotNullWhen(true)] out string? fixupReference)
1664 {
1665 string text = (_soap12 ? _r.GetAttribute("ref", "http://www.w3.org/2003/05/soap-encoding") : _r.GetAttribute("href"));
1666 if (text == null)
1667 {
1668 fixupReference = null;
1669 return false;
1670 }
1671 if (!_soap12)
1672 {
1673 if (!text.StartsWith('#'))
1674 {
1676 }
1677 fixupReference = text.Substring(1);
1678 }
1679 else
1680 {
1682 }
1683 if (_r.IsEmptyElement)
1684 {
1685 _r.Skip();
1686 }
1687 else
1688 {
1691 }
1692 return true;
1693 }
1694
1695 protected void AddTarget(string? id, object? o)
1696 {
1697 if (id == null)
1698 {
1699 if (_targetsWithoutIds == null)
1700 {
1702 }
1703 if (o != null)
1704 {
1706 }
1707 }
1708 else
1709 {
1710 if (_targets == null)
1711 {
1712 _targets = new Hashtable();
1713 }
1714 if (!_targets.Contains(id))
1715 {
1716 _targets.Add(id, o);
1717 }
1718 }
1719 }
1720
1721 protected void AddFixup(Fixup? fixup)
1722 {
1723 if (_fixups == null)
1724 {
1725 _fixups = new ArrayList();
1726 }
1727 _fixups.Add(fixup);
1728 }
1729
1731 {
1732 if (_collectionFixups == null)
1733 {
1735 }
1737 }
1738
1739 protected object GetTarget(string id)
1740 {
1741 object obj = ((_targets != null) ? _targets[id] : null);
1742 if (obj == null)
1743 {
1745 }
1746 Referenced(obj);
1747 return obj;
1748 }
1749
1750 protected void Referenced(object? o)
1751 {
1752 if (o != null)
1753 {
1754 if (_referencedTargets == null)
1755 {
1757 }
1759 }
1760 }
1761
1763 {
1764 if (_targets != null)
1765 {
1766 foreach (DictionaryEntry target in _targets)
1767 {
1768 if (_referencedTargets == null || !_referencedTargets.Contains(target.Value))
1769 {
1770 UnreferencedObject((string)target.Key, target.Value);
1771 }
1772 }
1773 }
1774 if (_targetsWithoutIds == null)
1775 {
1776 return;
1777 }
1778 foreach (object targetsWithoutId in _targetsWithoutIds)
1779 {
1781 {
1783 }
1784 }
1785 }
1786
1787 private void DoFixups()
1788 {
1789 if (_fixups == null)
1790 {
1791 return;
1792 }
1793 for (int i = 0; i < _fixups.Count; i++)
1794 {
1795 Fixup fixup = (Fixup)_fixups[i];
1796 fixup.Callback(fixup);
1797 }
1798 if (_collectionFixups != null)
1799 {
1800 for (int j = 0; j < _collectionFixups.Count; j++)
1801 {
1803 collectionFixup.Callback(collectionFixup.Collection, collectionFixup.CollectionItems);
1804 }
1805 }
1806 }
1807
1808 protected void FixupArrayRefs(object fixup)
1809 {
1811 Array array = (Array)fixup2.Source;
1812 for (int i = 0; i < array.Length; i++)
1813 {
1814 string text = fixup2.Ids[i];
1815 if (text != null)
1816 {
1817 object target = GetTarget(text);
1818 try
1819 {
1820 array.SetValue(target, i);
1821 }
1822 catch (InvalidCastException)
1823 {
1824 throw new InvalidOperationException(System.SR.Format(System.SR.XmlInvalidArrayRef, text, target.GetType().FullName, i.ToString(CultureInfo.InvariantCulture)));
1825 }
1826 }
1827 }
1828 }
1829
1830 [RequiresUnreferencedCode("calls GetArrayElementType")]
1831 private object ReadArray(string typeName, string typeNs)
1832 {
1833 Type type = null;
1835 if (_soap12)
1836 {
1839 Type type2 = (Type)_types[new XmlQualifiedName(typeName, typeNs)];
1840 if (attribute == null && attribute2 == null && (type2 == null || !type2.IsArray))
1841 {
1842 return null;
1843 }
1845 if (type2 != null)
1846 {
1848 }
1849 }
1850 else
1851 {
1853 if (attribute3 == null)
1854 {
1855 return null;
1856 }
1858 }
1859 if (soapArrayInfo.dimensions != 1)
1860 {
1862 }
1863 Type type3 = null;
1866 if (soapArrayInfo.qname.Length > 0)
1867 {
1870 }
1871 else
1872 {
1874 }
1875 if (_soap12 && type3 == typeof(object))
1876 {
1877 type3 = null;
1878 }
1879 bool flag;
1880 if (type3 == null)
1881 {
1882 if (!_soap12)
1883 {
1885 flag = true;
1886 }
1887 else
1888 {
1890 {
1892 }
1893 if (type3 != null)
1894 {
1895 flag = true;
1896 }
1897 else if (type == null)
1898 {
1899 type3 = typeof(object);
1900 flag = false;
1901 }
1902 else
1903 {
1904 type3 = type;
1906 if (xmlQualifiedName3 == null)
1907 {
1909 flag = true;
1910 }
1911 else
1912 {
1913 flag = type3.IsPrimitive;
1914 }
1915 if (xmlQualifiedName3 != null)
1916 {
1918 }
1919 }
1920 }
1921 }
1922 else
1923 {
1924 flag = type3.IsPrimitive;
1925 }
1926 if (!_soap12 && soapArrayInfo.jaggedDimensions > 0)
1927 {
1928 for (int i = 0; i < soapArrayInfo.jaggedDimensions; i++)
1929 {
1930 type3 = type3.MakeArrayType();
1931 }
1932 }
1933 if (_r.IsEmptyElement)
1934 {
1935 _r.Skip();
1936 return Array.CreateInstance(type3, 0);
1937 }
1939 _r.MoveToContent();
1940 int num = 0;
1941 Array array = null;
1942 if (type3.IsValueType)
1943 {
1944 if (!flag && !type3.IsEnum)
1945 {
1947 }
1948 while (_r.NodeType != XmlNodeType.EndElement)
1949 {
1951 array.SetValue(ReadReferencedElement(xmlQualifiedName2.Name, xmlQualifiedName2.Namespace), num);
1952 num++;
1953 _r.MoveToContent();
1954 }
1955 array = ShrinkArray(array, num, type3, isNullable: false);
1956 }
1957 else
1958 {
1959 string[] array2 = null;
1960 int num2 = 0;
1961 while (_r.NodeType != XmlNodeType.EndElement)
1962 {
1964 array2 = (string[])EnsureArrayIndex(array2, num2, typeof(string));
1965 string name;
1966 string ns;
1967 if (_r.NamespaceURI.Length != 0)
1968 {
1969 name = _r.LocalName;
1970 ns = (((object)_r.NamespaceURI != _soapNsID) ? _r.NamespaceURI : "http://www.w3.org/2001/XMLSchema");
1971 }
1972 else
1973 {
1974 name = xmlQualifiedName2.Name;
1975 ns = xmlQualifiedName2.Namespace;
1976 }
1977 array.SetValue(ReadReferencingElement(name, ns, out array2[num2]), num);
1978 num++;
1979 num2++;
1980 _r.MoveToContent();
1981 }
1982 if (_soap12 && type3 == typeof(object))
1983 {
1984 Type type4 = null;
1985 for (int j = 0; j < num; j++)
1986 {
1987 object value = array.GetValue(j);
1988 if (value != null)
1989 {
1990 Type type5 = value.GetType();
1991 if (type5.IsValueType)
1992 {
1993 type4 = null;
1994 break;
1995 }
1996 if (type4 == null || type5.IsAssignableFrom(type4))
1997 {
1998 type4 = type5;
1999 }
2000 else if (!type4.IsAssignableFrom(type5))
2001 {
2002 type4 = null;
2003 break;
2004 }
2005 }
2006 }
2007 if (type4 != null)
2008 {
2009 type3 = type4;
2010 }
2011 }
2012 array2 = (string[])ShrinkArray(array2, num2, typeof(string), isNullable: false);
2013 array = ShrinkArray(array, num, type3, isNullable: false);
2015 AddFixup(fixup);
2016 }
2018 return array;
2019 }
2020
2021 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
2022 protected abstract void InitCallbacks();
2023
2024 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
2025 protected void ReadReferencedElements()
2026 {
2027 _r.MoveToContent();
2028 while (_r.NodeType != XmlNodeType.EndElement && _r.NodeType != 0)
2029 {
2030 ReadReferencingElement(null, null, elementCanBeType: true, out string _);
2031 _r.MoveToContent();
2032 }
2033 DoFixups();
2035 }
2036
2037 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
2038 protected object? ReadReferencedElement()
2039 {
2040 return ReadReferencedElement(null, null);
2041 }
2042
2043 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
2044 protected object? ReadReferencedElement(string? name, string? ns)
2045 {
2046 string fixupReference;
2047 return ReadReferencingElement(name, ns, out fixupReference);
2048 }
2049
2050 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
2051 protected object? ReadReferencingElement(out string? fixupReference)
2052 {
2053 return ReadReferencingElement(null, null, out fixupReference);
2054 }
2055
2056 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
2057 protected object? ReadReferencingElement(string? name, string? ns, out string? fixupReference)
2058 {
2060 }
2061
2062 [MemberNotNull("_callbacks")]
2063 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly")]
2064 protected object? ReadReferencingElement(string? name, string? ns, bool elementCanBeType, out string? fixupReference)
2065 {
2066 object obj = null;
2068 _r.MoveToContent();
2070 {
2071 return null;
2072 }
2073 if (ReadNull())
2074 {
2075 return null;
2076 }
2077 string id = (_soap12 ? _r.GetAttribute("id", "http://www.w3.org/2003/05/soap-encoding") : _r.GetAttribute("id", null));
2078 if ((obj = ReadArray(name, ns)) == null)
2079 {
2081 if (xmlQualifiedName == null)
2082 {
2084 }
2087 }
2088 AddTarget(id, obj);
2089 return obj;
2090 }
2091
2092 [MemberNotNull("_callbacks")]
2093 [RequiresUnreferencedCode("calls InitCallbacks")]
2094 internal void EnsureCallbackTables()
2095 {
2096 if (_callbacks == null)
2097 {
2098 _callbacks = new Hashtable();
2099 _types = new Hashtable();
2100 XmlQualifiedName xmlQualifiedName = new XmlQualifiedName(_urTypeID, _r.NameTable.Add("http://www.w3.org/2001/XMLSchema"));
2102 _typesReverse = new Hashtable();
2104 InitCallbacks();
2105 }
2106 }
2107
2115
2116 protected void ReadEndElement()
2117 {
2118 while (_r.NodeType == XmlNodeType.Whitespace)
2119 {
2120 _r.Skip();
2121 }
2122 if (_r.NodeType == XmlNodeType.None)
2123 {
2124 _r.Skip();
2125 }
2126 else
2127 {
2129 }
2130 }
2131
2132 private object ReadXmlNodes(bool elementCanBeType)
2133 {
2135 string localName = Reader.LocalName;
2136 string namespaceURI = Reader.NamespaceURI;
2137 string name = Reader.Name;
2138 string text = null;
2139 string text2 = null;
2140 int num = 0;
2141 int lineNumber = -1;
2142 int linePosition = -1;
2143 XmlNode xmlNode = null;
2144 if (Reader.NodeType == XmlNodeType.Attribute)
2145 {
2147 xmlAttribute.Value = Reader.Value;
2149 }
2150 else
2151 {
2153 }
2154 GetCurrentPosition(out lineNumber, out linePosition);
2156 while (Reader.MoveToNextAttribute())
2157 {
2158 if (IsXmlnsAttribute(Reader.Name) || (Reader.Name == "id" && (!_soap12 || Reader.NamespaceURI == "http://www.w3.org/2003/05/soap-encoding")))
2159 {
2160 num++;
2161 }
2162 if ((object)Reader.LocalName == _typeID && ((object)Reader.NamespaceURI == _instanceNsID || (object)Reader.NamespaceURI == _instanceNs2000ID || (object)Reader.NamespaceURI == _instanceNs1999ID))
2163 {
2164 string value = Reader.Value;
2165 int num2 = value.LastIndexOf(':');
2166 text = ((num2 >= 0) ? value.Substring(num2 + 1) : value);
2167 text2 = Reader.LookupNamespace((num2 >= 0) ? value.Substring(0, num2) : "");
2168 }
2171 xmlElement?.SetAttributeNode(xmlAttribute2);
2172 }
2173 if (elementCanBeType && text == null)
2174 {
2175 text = localName;
2178 xmlAttribute3.Value = name;
2179 list.Add(xmlAttribute3);
2180 }
2181 if (text == "anyType" && ((object)text2 == _schemaNsID || (object)text2 == _schemaNs1999ID || (object)text2 == _schemaNs2000ID))
2182 {
2183 num++;
2184 }
2185 Reader.MoveToElement();
2186 if (Reader.IsEmptyElement)
2187 {
2188 Reader.Skip();
2189 }
2190 else
2191 {
2192 Reader.ReadStartElement();
2193 Reader.MoveToContent();
2194 while (Reader.NodeType != XmlNodeType.EndElement)
2195 {
2197 list.Add(xmlNode2);
2198 xmlElement?.AppendChild(xmlNode2);
2199 Reader.MoveToContent();
2200 }
2202 }
2203 if (list.Count <= num)
2204 {
2205 return new object();
2206 }
2207 XmlNode[] result = list.ToArray();
2208 UnknownNode(xmlNode, null, null);
2209 return result;
2210 }
2211
2213 {
2214 }
2215}
static unsafe Array CreateInstance(Type elementType, int length)
Definition Array.cs:473
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
Definition Buffer.cs:102
virtual int Add(object? value)
void Add(TKey key, TValue value)
virtual bool Contains(object key)
Definition Hashtable.cs:719
virtual void Add(object key, object? value)
Definition Hashtable.cs:676
static CultureInfo InvariantCulture
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static string XmlInvalidHref
Definition SR.cs:1556
static string XmlInvalidCast
Definition SR.cs:1680
static string XmlUndefinedAlias
Definition SR.cs:1640
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlInvalidArraySyntax
Definition SR.cs:1546
static string XmlUnknownConstant
Definition SR.cs:1526
static string XmlConstructorHasSecurityAttributes
Definition SR.cs:1696
static string XmlReadOnlyCollection
Definition SR.cs:1624
static string XmlSerializableBadDerivation
Definition SR.cs:1768
static string XmlAbstractType
Definition SR.cs:1560
static string XmlInvalidArrayRef
Definition SR.cs:1684
static string XmlMissingHref
Definition SR.cs:1554
static string XmlInvalidArrayTypeName
Definition SR.cs:1538
static string XmlInvalidArrayDimentions
Definition SR.cs:1536
static string XmlRpcArrayOfValueTypes
Definition SR.cs:1630
static string XmlInvalidArrayTypeNamespace
Definition SR.cs:1540
static string XmlInvalidCastWithId
Definition SR.cs:1682
static string XmlUnknownNode
Definition SR.cs:1524
static string XmlEmptyArrayType
Definition SR.cs:1544
static string XmlUnknownType
Definition SR.cs:1558
static string XmlInvalidArrayLength
Definition SR.cs:1552
static string XmlSerializableMissingClrType
Definition SR.cs:1770
static string XmlConstructorInaccessible
Definition SR.cs:1410
static string XmlMissingArrayType
Definition SR.cs:1542
static string XmlInvalidNullCast
Definition SR.cs:1686
static string XmlMismatchedArrayBrackets
Definition SR.cs:1550
Definition SR.cs:7
static Assembly Get(string fullName)
static Type GetArrayElementType(Type type, string memberInfo)
Definition TypeScope.cs:576
static long ToEnum(string val, Hashtable vals, string typeName, bool validate)
CollectionFixup(object? collection, XmlSerializationCollectionFixupCallback callback, object collectionItems)
readonly XmlSerializationCollectionFixupCallback _callback
Fixup(object? o, XmlSerializationFixupCallback callback, int count)
Fixup(object? o, XmlSerializationFixupCallback callback, string?[]? ids)
void UnknownAttribute(object? o, XmlAttribute attr, string? qnames)
void UnknownNode(XmlNode unknownNode, object o, string qnames)
static ? Assembly ResolveDynamicAssembly(string assemblyFullName)
void Init(XmlReader r, XmlDeserializationEvents events, string encodingStyle, TempAssembly tempAssembly)
object ReadTypedPrimitive(XmlQualifiedName type, bool elementCanBeType)
Array? ShrinkArray(Array? a, int length, Type elementType, bool isNullable)
static long ToEnum(string value, Hashtable h, string typeName)
void AddReadCallback(string name, string ns, Type type, XmlSerializationReadCallback read)
object ReadArray(string typeName, string typeNs)
Exception CreateMissingIXmlSerializableType(string? name, string? ns, string? clrType)
SoapArrayInfo ParseSoap12ArrayType(string itemType, string arraySize)
Exception CreateUnknownTypeException(XmlQualifiedName type)
Exception CreateInvalidCastException(Type type, object? value, string? id)
Exception CreateBadDerivationException(string? xsdDerived, string? nsDerived, string? xsdBase, string? nsBase, string? clrDerived, string? clrBase)
void UnknownElement(object? o, XmlElement elem, string? qnames)
Exception CreateInvalidCastException(Type type, object? value)
Exception CreateUnknownConstantException(string? value, Type enumType)
Array EnsureArrayIndex(Array? a, int index, Type elementType)
IXmlSerializable ReadSerializable(IXmlSerializable serializable, bool wrappedAny)
bool ReadReference([NotNullWhen(true)] out string? fixupReference)
object? ReadReferencedElement(string? name, string? ns)
XmlQualifiedName ToXmlQualifiedName(string value, bool decodeName)
object? ReadReferencingElement(string? name, string? ns, bool elementCanBeType, out string? fixupReference)
Type GetPrimitiveType(XmlQualifiedName typeName, bool throwOnUnknown)
void GetCurrentPosition(out int lineNumber, out int linePosition)
object? ReadReferencingElement(out string? fixupReference)
void CheckReaderCount(ref int whileIterations, ref int readerCount)
IXmlSerializable ReadSerializable(IXmlSerializable serializable)
Exception CreateAbstractTypeException(string name, string? ns)
object? ReadReferencingElement(string? name, string? ns, out string? fixupReference)
static XmlQualifiedName GetPrimitiveTypeNameInternal(Type type)
override string Value
static bool ToBoolean(string s)
static DateTimeOffset ToDateTimeOffset(string s)
static uint ToUInt32(string s)
static ? string DecodeName(string? name)
Definition XmlConvert.cs:55
static int ToInt32(string s)
static short ToInt16(string s)
static float ToSingle(string s)
static TimeSpan ToTimeSpan(string s)
static double ToDouble(string s)
static sbyte ToSByte(string s)
static decimal ToDecimal(string s)
static ulong ToUInt64(string s)
static ushort ToUInt16(string s)
static byte ToByte(string s)
static long ToInt64(string s)
virtual ? XmlNode ReadNode(XmlReader reader)
void SetBaseURI(string inBaseURI)
XmlElement CreateElement(string name)
XmlAttribute CreateAttribute(string name)
string Add(char[] array, int offset, int length)
static readonly XmlQualifiedName Empty
string? GetAttribute(string name)
virtual void Skip()
Definition XmlReader.cs:532
virtual void ReadStartElement()
Definition XmlReader.cs:629
virtual void ReadEndElement()
Definition XmlReader.cs:751
virtual int ReadElementContentAsBase64(byte[] buffer, int index, int count)
Definition XmlReader.cs:549
string? LookupNamespace(string prefix)
virtual XmlNodeType MoveToContent()
Definition XmlReader.cs:604
virtual string ReadElementString()
Definition XmlReader.cs:667
XmlNodeType NodeType
Definition XmlReader.cs:62
virtual string ReadString()
Definition XmlReader.cs:570
XmlNameTable NameTable
Definition XmlReader.cs:116
virtual int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
Definition XmlReader.cs:559
delegate void XmlSerializationCollectionFixupCallback(object? collection, object? collectionItems)
delegate void XmlSerializationFixupCallback(object fixup)
delegate? object XmlSerializationReadCallback()