mscorlib(4.0.0.0) API with additions
XmlSerializationReader.cs
1 using System.Collections;
4 using System.Reflection;
5 using System.Threading;
7 
9 {
12  {
13  private struct SoapArrayInfo
14  {
15  public string qname;
16 
17  public int dimensions;
18 
19  public int length;
20 
21  public int jaggedDimensions;
22  }
23 
25  protected class Fixup
26  {
27  private XmlSerializationFixupCallback callback;
28 
29  private object source;
30 
31  private string[] ids;
32 
36 
39  public object Source
40  {
41  get
42  {
43  return source;
44  }
45  set
46  {
47  source = value;
48  }
49  }
50 
53  public string[] Ids => ids;
54 
59  public Fixup(object o, XmlSerializationFixupCallback callback, int count)
60  : this(o, callback, new string[count])
61  {
62  }
63 
68  public Fixup(object o, XmlSerializationFixupCallback callback, string[] ids)
69  {
70  this.callback = callback;
71  Source = o;
72  this.ids = ids;
73  }
74  }
75 
77  protected class CollectionFixup
78  {
80 
81  private object collection;
82 
83  private object collectionItems;
84 
88 
91  public object Collection => collection;
92 
95  public object CollectionItems => collectionItems;
96 
101  public CollectionFixup(object collection, XmlSerializationCollectionFixupCallback callback, object collectionItems)
102  {
103  this.callback = callback;
104  this.collection = collection;
105  this.collectionItems = collectionItems;
106  }
107  }
108 
109  private XmlReader r;
110 
111  private XmlCountingReader countingReader;
112 
113  private XmlDocument d;
114 
115  private Hashtable callbacks;
116 
117  private Hashtable types;
118 
119  private Hashtable typesReverse;
120 
121  private XmlDeserializationEvents events;
122 
123  private Hashtable targets;
124 
125  private Hashtable referencedTargets;
126 
127  private ArrayList targetsWithoutIds;
128 
129  private ArrayList fixups;
130 
131  private ArrayList collectionFixups;
132 
133  private bool soap12;
134 
135  private bool isReturnValue;
136 
137  private bool decodeName = true;
138 
139  private string schemaNsID;
140 
141  private string schemaNs1999ID;
142 
143  private string schemaNs2000ID;
144 
145  private string schemaNonXsdTypesNsID;
146 
147  private string instanceNsID;
148 
149  private string instanceNs2000ID;
150 
151  private string instanceNs1999ID;
152 
153  private string soapNsID;
154 
155  private string soap12NsID;
156 
157  private string schemaID;
158 
159  private string wsdlNsID;
160 
161  private string wsdlArrayTypeID;
162 
163  private string nullID;
164 
165  private string nilID;
166 
167  private string typeID;
168 
169  private string arrayTypeID;
170 
171  private string itemTypeID;
172 
173  private string arraySizeID;
174 
175  private string arrayID;
176 
177  private string urTypeID;
178 
179  private string stringID;
180 
181  private string intID;
182 
183  private string booleanID;
184 
185  private string shortID;
186 
187  private string longID;
188 
189  private string floatID;
190 
191  private string doubleID;
192 
193  private string decimalID;
194 
195  private string dateTimeID;
196 
197  private string qnameID;
198 
199  private string dateID;
200 
201  private string timeID;
202 
203  private string hexBinaryID;
204 
205  private string base64BinaryID;
206 
207  private string base64ID;
208 
209  private string unsignedByteID;
210 
211  private string byteID;
212 
213  private string unsignedShortID;
214 
215  private string unsignedIntID;
216 
217  private string unsignedLongID;
218 
219  private string oldDecimalID;
220 
221  private string oldTimeInstantID;
222 
223  private string anyURIID;
224 
225  private string durationID;
226 
227  private string ENTITYID;
228 
229  private string ENTITIESID;
230 
231  private string gDayID;
232 
233  private string gMonthID;
234 
235  private string gMonthDayID;
236 
237  private string gYearID;
238 
239  private string gYearMonthID;
240 
241  private string IDID;
242 
243  private string IDREFID;
244 
245  private string IDREFSID;
246 
247  private string integerID;
248 
249  private string languageID;
250 
251  private string NameID;
252 
253  private string NCNameID;
254 
255  private string NMTOKENID;
256 
257  private string NMTOKENSID;
258 
259  private string negativeIntegerID;
260 
261  private string nonPositiveIntegerID;
262 
263  private string nonNegativeIntegerID;
264 
265  private string normalizedStringID;
266 
267  private string NOTATIONID;
268 
269  private string positiveIntegerID;
270 
271  private string tokenID;
272 
273  private string charID;
274 
275  private string guidID;
276 
277  private string timeSpanID;
278 
279  private static bool checkDeserializeAdvances;
280 
284  protected bool DecodeName
285  {
286  get
287  {
288  return decodeName;
289  }
290  set
291  {
292  decodeName = value;
293  }
294  }
295 
298  protected XmlReader Reader => r;
299 
302  protected int ReaderCount
303  {
304  get
305  {
306  if (!checkDeserializeAdvances)
307  {
308  return 0;
309  }
310  return countingReader.AdvanceCount;
311  }
312  }
313 
316  protected XmlDocument Document
317  {
318  get
319  {
320  if (d == null)
321  {
322  d = new XmlDocument(r.NameTable);
323  d.SetBaseURI(r.BaseURI);
324  }
325  return d;
326  }
327  }
328 
332  protected bool IsReturnValue
333  {
334  get
335  {
336  if (isReturnValue)
337  {
338  return !soap12;
339  }
340  return false;
341  }
342  set
343  {
344  isReturnValue = value;
345  }
346  }
347 
348  static XmlSerializationReader()
349  {
350  checkDeserializeAdvances = ((ConfigurationManager.GetSection(ConfigurationStrings.XmlSerializerSectionPath) as XmlSerializerSection)?.CheckDeserializeAdvances ?? false);
351  }
352 
354  protected abstract void InitIDs();
355 
356  internal void Init(XmlReader r, XmlDeserializationEvents events, string encodingStyle, TempAssembly tempAssembly)
357  {
358  this.events = events;
359  if (checkDeserializeAdvances)
360  {
361  countingReader = new XmlCountingReader(r);
362  this.r = countingReader;
363  }
364  else
365  {
366  this.r = r;
367  }
368  d = null;
369  soap12 = (encodingStyle == "http://www.w3.org/2003/05/soap-encoding");
370  Init(tempAssembly);
371  schemaNsID = r.NameTable.Add("http://www.w3.org/2001/XMLSchema");
372  schemaNs2000ID = r.NameTable.Add("http://www.w3.org/2000/10/XMLSchema");
373  schemaNs1999ID = r.NameTable.Add("http://www.w3.org/1999/XMLSchema");
374  schemaNonXsdTypesNsID = r.NameTable.Add("http://microsoft.com/wsdl/types/");
375  instanceNsID = r.NameTable.Add("http://www.w3.org/2001/XMLSchema-instance");
376  instanceNs2000ID = r.NameTable.Add("http://www.w3.org/2000/10/XMLSchema-instance");
377  instanceNs1999ID = r.NameTable.Add("http://www.w3.org/1999/XMLSchema-instance");
378  soapNsID = r.NameTable.Add("http://schemas.xmlsoap.org/soap/encoding/");
379  soap12NsID = r.NameTable.Add("http://www.w3.org/2003/05/soap-encoding");
380  schemaID = r.NameTable.Add("schema");
381  wsdlNsID = r.NameTable.Add("http://schemas.xmlsoap.org/wsdl/");
382  wsdlArrayTypeID = r.NameTable.Add("arrayType");
383  nullID = r.NameTable.Add("null");
384  nilID = r.NameTable.Add("nil");
385  typeID = r.NameTable.Add("type");
386  arrayTypeID = r.NameTable.Add("arrayType");
387  itemTypeID = r.NameTable.Add("itemType");
388  arraySizeID = r.NameTable.Add("arraySize");
389  arrayID = r.NameTable.Add("Array");
390  urTypeID = r.NameTable.Add("anyType");
391  InitIDs();
392  }
393 
397  protected static Assembly ResolveDynamicAssembly(string assemblyFullName)
398  {
399  return DynamicAssemblies.Get(assemblyFullName);
400  }
401 
402  private void InitPrimitiveIDs()
403  {
404  if (tokenID == null)
405  {
406  object obj = r.NameTable.Add("http://www.w3.org/2001/XMLSchema");
407  object obj2 = r.NameTable.Add("http://microsoft.com/wsdl/types/");
408  stringID = r.NameTable.Add("string");
409  intID = r.NameTable.Add("int");
410  booleanID = r.NameTable.Add("boolean");
411  shortID = r.NameTable.Add("short");
412  longID = r.NameTable.Add("long");
413  floatID = r.NameTable.Add("float");
414  doubleID = r.NameTable.Add("double");
415  decimalID = r.NameTable.Add("decimal");
416  dateTimeID = r.NameTable.Add("dateTime");
417  qnameID = r.NameTable.Add("QName");
418  dateID = r.NameTable.Add("date");
419  timeID = r.NameTable.Add("time");
420  hexBinaryID = r.NameTable.Add("hexBinary");
421  base64BinaryID = r.NameTable.Add("base64Binary");
422  unsignedByteID = r.NameTable.Add("unsignedByte");
423  byteID = r.NameTable.Add("byte");
424  unsignedShortID = r.NameTable.Add("unsignedShort");
425  unsignedIntID = r.NameTable.Add("unsignedInt");
426  unsignedLongID = r.NameTable.Add("unsignedLong");
427  oldDecimalID = r.NameTable.Add("decimal");
428  oldTimeInstantID = r.NameTable.Add("timeInstant");
429  charID = r.NameTable.Add("char");
430  guidID = r.NameTable.Add("guid");
431  if (System.LocalAppContextSwitches.EnableTimeSpanSerialization)
432  {
433  timeSpanID = r.NameTable.Add("TimeSpan");
434  }
435  base64ID = r.NameTable.Add("base64");
436  anyURIID = r.NameTable.Add("anyURI");
437  durationID = r.NameTable.Add("duration");
438  ENTITYID = r.NameTable.Add("ENTITY");
439  ENTITIESID = r.NameTable.Add("ENTITIES");
440  gDayID = r.NameTable.Add("gDay");
441  gMonthID = r.NameTable.Add("gMonth");
442  gMonthDayID = r.NameTable.Add("gMonthDay");
443  gYearID = r.NameTable.Add("gYear");
444  gYearMonthID = r.NameTable.Add("gYearMonth");
445  IDID = r.NameTable.Add("ID");
446  IDREFID = r.NameTable.Add("IDREF");
447  IDREFSID = r.NameTable.Add("IDREFS");
448  integerID = r.NameTable.Add("integer");
449  languageID = r.NameTable.Add("language");
450  NameID = r.NameTable.Add("Name");
451  NCNameID = r.NameTable.Add("NCName");
452  NMTOKENID = r.NameTable.Add("NMTOKEN");
453  NMTOKENSID = r.NameTable.Add("NMTOKENS");
454  negativeIntegerID = r.NameTable.Add("negativeInteger");
455  nonNegativeIntegerID = r.NameTable.Add("nonNegativeInteger");
456  nonPositiveIntegerID = r.NameTable.Add("nonPositiveInteger");
457  normalizedStringID = r.NameTable.Add("normalizedString");
458  NOTATIONID = r.NameTable.Add("NOTATION");
459  positiveIntegerID = r.NameTable.Add("positiveInteger");
460  tokenID = r.NameTable.Add("token");
461  }
462  }
463 
467  {
468  string attribute = r.GetAttribute(typeID, instanceNsID);
469  if (attribute == null)
470  {
471  attribute = r.GetAttribute(typeID, instanceNs2000ID);
472  if (attribute == null)
473  {
474  attribute = r.GetAttribute(typeID, instanceNs1999ID);
475  if (attribute == null)
476  {
477  return null;
478  }
479  }
480  }
481  return ToXmlQualifiedName(attribute, decodeName: false);
482  }
483 
484  private Type GetPrimitiveType(XmlQualifiedName typeName, bool throwOnUnknown)
485  {
486  InitPrimitiveIDs();
487  if ((object)typeName.Namespace == schemaNsID || (object)typeName.Namespace == soapNsID || (object)typeName.Namespace == soap12NsID)
488  {
489  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)
490  {
491  return typeof(string);
492  }
493  if ((object)typeName.Name == intID)
494  {
495  return typeof(int);
496  }
497  if ((object)typeName.Name == booleanID)
498  {
499  return typeof(bool);
500  }
501  if ((object)typeName.Name == shortID)
502  {
503  return typeof(short);
504  }
505  if ((object)typeName.Name == longID)
506  {
507  return typeof(long);
508  }
509  if ((object)typeName.Name == floatID)
510  {
511  return typeof(float);
512  }
513  if ((object)typeName.Name == doubleID)
514  {
515  return typeof(double);
516  }
517  if ((object)typeName.Name == decimalID)
518  {
519  return typeof(decimal);
520  }
521  if ((object)typeName.Name == dateTimeID)
522  {
523  return typeof(DateTime);
524  }
525  if ((object)typeName.Name == qnameID)
526  {
527  return typeof(XmlQualifiedName);
528  }
529  if ((object)typeName.Name == dateID)
530  {
531  return typeof(DateTime);
532  }
533  if ((object)typeName.Name == timeID)
534  {
535  return typeof(DateTime);
536  }
537  if ((object)typeName.Name == hexBinaryID)
538  {
539  return typeof(byte[]);
540  }
541  if ((object)typeName.Name == base64BinaryID)
542  {
543  return typeof(byte[]);
544  }
545  if ((object)typeName.Name == unsignedByteID)
546  {
547  return typeof(byte);
548  }
549  if ((object)typeName.Name == byteID)
550  {
551  return typeof(sbyte);
552  }
553  if ((object)typeName.Name == unsignedShortID)
554  {
555  return typeof(ushort);
556  }
557  if ((object)typeName.Name == unsignedIntID)
558  {
559  return typeof(uint);
560  }
561  if ((object)typeName.Name == unsignedLongID)
562  {
563  return typeof(ulong);
564  }
565  throw CreateUnknownTypeException(typeName);
566  }
567  if ((object)typeName.Namespace == schemaNs2000ID || (object)typeName.Namespace == schemaNs1999ID)
568  {
569  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)
570  {
571  return typeof(string);
572  }
573  if ((object)typeName.Name == intID)
574  {
575  return typeof(int);
576  }
577  if ((object)typeName.Name == booleanID)
578  {
579  return typeof(bool);
580  }
581  if ((object)typeName.Name == shortID)
582  {
583  return typeof(short);
584  }
585  if ((object)typeName.Name == longID)
586  {
587  return typeof(long);
588  }
589  if ((object)typeName.Name == floatID)
590  {
591  return typeof(float);
592  }
593  if ((object)typeName.Name == doubleID)
594  {
595  return typeof(double);
596  }
597  if ((object)typeName.Name == oldDecimalID)
598  {
599  return typeof(decimal);
600  }
601  if ((object)typeName.Name == oldTimeInstantID)
602  {
603  return typeof(DateTime);
604  }
605  if ((object)typeName.Name == qnameID)
606  {
607  return typeof(XmlQualifiedName);
608  }
609  if ((object)typeName.Name == dateID)
610  {
611  return typeof(DateTime);
612  }
613  if ((object)typeName.Name == timeID)
614  {
615  return typeof(DateTime);
616  }
617  if ((object)typeName.Name == hexBinaryID)
618  {
619  return typeof(byte[]);
620  }
621  if ((object)typeName.Name == byteID)
622  {
623  return typeof(sbyte);
624  }
625  if ((object)typeName.Name == unsignedShortID)
626  {
627  return typeof(ushort);
628  }
629  if ((object)typeName.Name == unsignedIntID)
630  {
631  return typeof(uint);
632  }
633  if ((object)typeName.Name == unsignedLongID)
634  {
635  return typeof(ulong);
636  }
637  throw CreateUnknownTypeException(typeName);
638  }
639  if ((object)typeName.Namespace == schemaNonXsdTypesNsID)
640  {
641  if ((object)typeName.Name == charID)
642  {
643  return typeof(char);
644  }
645  if ((object)typeName.Name == guidID)
646  {
647  return typeof(Guid);
648  }
649  throw CreateUnknownTypeException(typeName);
650  }
651  if (throwOnUnknown)
652  {
653  throw CreateUnknownTypeException(typeName);
654  }
655  return null;
656  }
657 
658  private bool IsPrimitiveNamespace(string ns)
659  {
660  if ((object)ns != schemaNsID && (object)ns != schemaNonXsdTypesNsID && (object)ns != soapNsID && (object)ns != soap12NsID && (object)ns != schemaNs2000ID)
661  {
662  return (object)ns == schemaNs1999ID;
663  }
664  return true;
665  }
666 
667  private string ReadStringValue()
668  {
669  if (r.IsEmptyElement)
670  {
671  r.Skip();
672  return string.Empty;
673  }
674  r.ReadStartElement();
675  string result = r.ReadString();
676  ReadEndElement();
677  return result;
678  }
679 
680  private XmlQualifiedName ReadXmlQualifiedName()
681  {
682  bool flag = false;
683  string value;
684  if (r.IsEmptyElement)
685  {
686  value = string.Empty;
687  flag = true;
688  }
689  else
690  {
691  r.ReadStartElement();
692  value = r.ReadString();
693  }
694  XmlQualifiedName result = ToXmlQualifiedName(value);
695  if (flag)
696  {
697  r.Skip();
698  }
699  else
700  {
701  ReadEndElement();
702  }
703  return result;
704  }
705 
706  private byte[] ReadByteArray(bool isBase64)
707  {
708  ArrayList arrayList = new ArrayList();
709  int num = 1024;
710  int num2 = -1;
711  int num3 = 0;
712  int num4 = 0;
713  byte[] array = new byte[num];
714  arrayList.Add(array);
715  while (num2 != 0)
716  {
717  if (num3 == array.Length)
718  {
719  num = Math.Min(num * 2, 65536);
720  array = new byte[num];
721  num3 = 0;
722  arrayList.Add(array);
723  }
724  num2 = ((!isBase64) ? r.ReadElementContentAsBinHex(array, num3, array.Length - num3) : r.ReadElementContentAsBase64(array, num3, array.Length - num3));
725  num3 += num2;
726  num4 += num2;
727  }
728  byte[] array2 = new byte[num4];
729  num3 = 0;
730  foreach (byte[] item in arrayList)
731  {
732  num = Math.Min(item.Length, num4);
733  if (num > 0)
734  {
735  Buffer.BlockCopy(item, 0, array2, num3, num);
736  num3 += num;
737  num4 -= num;
738  }
739  }
740  arrayList.Clear();
741  return array2;
742  }
743 
747  protected object ReadTypedPrimitive(XmlQualifiedName type)
748  {
749  return ReadTypedPrimitive(type, elementCanBeType: false);
750  }
751 
752  private object ReadTypedPrimitive(XmlQualifiedName type, bool elementCanBeType)
753  {
754  InitPrimitiveIDs();
755  object obj = null;
756  if (!IsPrimitiveNamespace(type.Namespace) || (object)type.Name == urTypeID)
757  {
758  return ReadXmlNodes(elementCanBeType);
759  }
760  if ((object)type.Namespace == schemaNsID || (object)type.Namespace == soapNsID || (object)type.Namespace == soap12NsID)
761  {
762  if ((object)type.Name == stringID || (object)type.Name == normalizedStringID)
763  {
764  return ReadStringValue();
765  }
766  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)
767  {
768  return CollapseWhitespace(ReadStringValue());
769  }
770  if ((object)type.Name == intID)
771  {
772  return XmlConvert.ToInt32(ReadStringValue());
773  }
774  if ((object)type.Name == booleanID)
775  {
776  return XmlConvert.ToBoolean(ReadStringValue());
777  }
778  if ((object)type.Name == shortID)
779  {
780  return XmlConvert.ToInt16(ReadStringValue());
781  }
782  if ((object)type.Name == longID)
783  {
784  return XmlConvert.ToInt64(ReadStringValue());
785  }
786  if ((object)type.Name == floatID)
787  {
788  return XmlConvert.ToSingle(ReadStringValue());
789  }
790  if ((object)type.Name == doubleID)
791  {
792  return XmlConvert.ToDouble(ReadStringValue());
793  }
794  if ((object)type.Name == decimalID)
795  {
796  return XmlConvert.ToDecimal(ReadStringValue());
797  }
798  if ((object)type.Name == dateTimeID)
799  {
800  return ToDateTime(ReadStringValue());
801  }
802  if ((object)type.Name == qnameID)
803  {
804  return ReadXmlQualifiedName();
805  }
806  if ((object)type.Name == dateID)
807  {
808  return ToDate(ReadStringValue());
809  }
810  if ((object)type.Name == timeID)
811  {
812  return ToTime(ReadStringValue());
813  }
814  if ((object)type.Name == unsignedByteID)
815  {
816  return XmlConvert.ToByte(ReadStringValue());
817  }
818  if ((object)type.Name == byteID)
819  {
820  return XmlConvert.ToSByte(ReadStringValue());
821  }
822  if ((object)type.Name == unsignedShortID)
823  {
824  return XmlConvert.ToUInt16(ReadStringValue());
825  }
826  if ((object)type.Name == unsignedIntID)
827  {
828  return XmlConvert.ToUInt32(ReadStringValue());
829  }
830  if ((object)type.Name == unsignedLongID)
831  {
832  return XmlConvert.ToUInt64(ReadStringValue());
833  }
834  if ((object)type.Name == hexBinaryID)
835  {
836  return ToByteArrayHex(isNull: false);
837  }
838  if ((object)type.Name == base64BinaryID)
839  {
840  return ToByteArrayBase64(isNull: false);
841  }
842  if ((object)type.Name == base64ID && ((object)type.Namespace == soapNsID || (object)type.Namespace == soap12NsID))
843  {
844  return ToByteArrayBase64(isNull: false);
845  }
846  return ReadXmlNodes(elementCanBeType);
847  }
848  if ((object)type.Namespace == schemaNs2000ID || (object)type.Namespace == schemaNs1999ID)
849  {
850  if ((object)type.Name == stringID || (object)type.Name == normalizedStringID)
851  {
852  return ReadStringValue();
853  }
854  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)
855  {
856  return CollapseWhitespace(ReadStringValue());
857  }
858  if ((object)type.Name == intID)
859  {
860  return XmlConvert.ToInt32(ReadStringValue());
861  }
862  if ((object)type.Name == booleanID)
863  {
864  return XmlConvert.ToBoolean(ReadStringValue());
865  }
866  if ((object)type.Name == shortID)
867  {
868  return XmlConvert.ToInt16(ReadStringValue());
869  }
870  if ((object)type.Name == longID)
871  {
872  return XmlConvert.ToInt64(ReadStringValue());
873  }
874  if ((object)type.Name == floatID)
875  {
876  return XmlConvert.ToSingle(ReadStringValue());
877  }
878  if ((object)type.Name == doubleID)
879  {
880  return XmlConvert.ToDouble(ReadStringValue());
881  }
882  if ((object)type.Name == oldDecimalID)
883  {
884  return XmlConvert.ToDecimal(ReadStringValue());
885  }
886  if ((object)type.Name == oldTimeInstantID)
887  {
888  return ToDateTime(ReadStringValue());
889  }
890  if ((object)type.Name == qnameID)
891  {
892  return ReadXmlQualifiedName();
893  }
894  if ((object)type.Name == dateID)
895  {
896  return ToDate(ReadStringValue());
897  }
898  if ((object)type.Name == timeID)
899  {
900  return ToTime(ReadStringValue());
901  }
902  if ((object)type.Name == unsignedByteID)
903  {
904  return XmlConvert.ToByte(ReadStringValue());
905  }
906  if ((object)type.Name == byteID)
907  {
908  return XmlConvert.ToSByte(ReadStringValue());
909  }
910  if ((object)type.Name == unsignedShortID)
911  {
912  return XmlConvert.ToUInt16(ReadStringValue());
913  }
914  if ((object)type.Name == unsignedIntID)
915  {
916  return XmlConvert.ToUInt32(ReadStringValue());
917  }
918  if ((object)type.Name == unsignedLongID)
919  {
920  return XmlConvert.ToUInt64(ReadStringValue());
921  }
922  return ReadXmlNodes(elementCanBeType);
923  }
924  if ((object)type.Namespace == schemaNonXsdTypesNsID)
925  {
926  if ((object)type.Name == charID)
927  {
928  return ToChar(ReadStringValue());
929  }
930  if ((object)type.Name == guidID)
931  {
932  return new Guid(CollapseWhitespace(ReadStringValue()));
933  }
934  if ((object)type.Name == timeSpanID && System.LocalAppContextSwitches.EnableTimeSpanSerialization)
935  {
936  return XmlConvert.ToTimeSpan(ReadStringValue());
937  }
938  return ReadXmlNodes(elementCanBeType);
939  }
940  return ReadXmlNodes(elementCanBeType);
941  }
942 
946  protected object ReadTypedNull(XmlQualifiedName type)
947  {
948  InitPrimitiveIDs();
949  object obj = null;
950  if (!IsPrimitiveNamespace(type.Namespace) || (object)type.Name == urTypeID)
951  {
952  return null;
953  }
954  if ((object)type.Namespace == schemaNsID || (object)type.Namespace == soapNsID || (object)type.Namespace == soap12NsID)
955  {
956  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)
957  {
958  return null;
959  }
960  if ((object)type.Name == intID)
961  {
962  return null;
963  }
964  if ((object)type.Name == booleanID)
965  {
966  return null;
967  }
968  if ((object)type.Name == shortID)
969  {
970  return null;
971  }
972  if ((object)type.Name == longID)
973  {
974  return null;
975  }
976  if ((object)type.Name == floatID)
977  {
978  return null;
979  }
980  if ((object)type.Name == doubleID)
981  {
982  return null;
983  }
984  if ((object)type.Name == decimalID)
985  {
986  return null;
987  }
988  if ((object)type.Name == dateTimeID)
989  {
990  return null;
991  }
992  if ((object)type.Name == qnameID)
993  {
994  return null;
995  }
996  if ((object)type.Name == dateID)
997  {
998  return null;
999  }
1000  if ((object)type.Name == timeID)
1001  {
1002  return null;
1003  }
1004  if ((object)type.Name == unsignedByteID)
1005  {
1006  return null;
1007  }
1008  if ((object)type.Name == byteID)
1009  {
1010  return null;
1011  }
1012  if ((object)type.Name == unsignedShortID)
1013  {
1014  return null;
1015  }
1016  if ((object)type.Name == unsignedIntID)
1017  {
1018  return null;
1019  }
1020  if ((object)type.Name == unsignedLongID)
1021  {
1022  return null;
1023  }
1024  if ((object)type.Name == hexBinaryID)
1025  {
1026  return null;
1027  }
1028  if ((object)type.Name == base64BinaryID)
1029  {
1030  return null;
1031  }
1032  if ((object)type.Name == base64ID && ((object)type.Namespace == soapNsID || (object)type.Namespace == soap12NsID))
1033  {
1034  return null;
1035  }
1036  return null;
1037  }
1038  if ((object)type.Namespace == schemaNonXsdTypesNsID)
1039  {
1040  if ((object)type.Name == charID)
1041  {
1042  return null;
1043  }
1044  if ((object)type.Name == guidID)
1045  {
1046  return null;
1047  }
1048  if ((object)type.Name == timeSpanID && System.LocalAppContextSwitches.EnableTimeSpanSerialization)
1049  {
1050  return null;
1051  }
1052  return null;
1053  }
1054  return null;
1055  }
1056 
1061  protected bool IsXmlnsAttribute(string name)
1062  {
1063  if (!name.StartsWith("xmlns", StringComparison.Ordinal))
1064  {
1065  return false;
1066  }
1067  if (name.Length == 5)
1068  {
1069  return true;
1070  }
1071  return name[5] == ':';
1072  }
1073 
1076  protected void ParseWsdlArrayType(XmlAttribute attr)
1077  {
1078  if ((object)attr.LocalName == wsdlArrayTypeID && (object)attr.NamespaceURI == wsdlNsID)
1079  {
1080  int num = attr.Value.LastIndexOf(':');
1081  if (num < 0)
1082  {
1083  attr.Value = r.LookupNamespace("") + ":" + attr.Value;
1084  }
1085  else
1086  {
1087  attr.Value = r.LookupNamespace(attr.Value.Substring(0, num)) + ":" + attr.Value.Substring(num + 1);
1088  }
1089  }
1090  }
1091 
1095  protected bool ReadNull()
1096  {
1097  if (!GetNullAttr())
1098  {
1099  return false;
1100  }
1101  if (r.IsEmptyElement)
1102  {
1103  r.Skip();
1104  return true;
1105  }
1106  r.ReadStartElement();
1107  int whileIterations = 0;
1108  int readerCount = ReaderCount;
1109  while (r.NodeType != XmlNodeType.EndElement)
1110  {
1111  UnknownNode(null);
1112  CheckReaderCount(ref whileIterations, ref readerCount);
1113  }
1114  ReadEndElement();
1115  return true;
1116  }
1117 
1121  protected bool GetNullAttr()
1122  {
1123  string attribute = r.GetAttribute(nilID, instanceNsID);
1124  if (attribute == null)
1125  {
1126  attribute = r.GetAttribute(nullID, instanceNsID);
1127  }
1128  if (attribute == null)
1129  {
1130  attribute = r.GetAttribute(nullID, instanceNs2000ID);
1131  if (attribute == null)
1132  {
1133  attribute = r.GetAttribute(nullID, instanceNs1999ID);
1134  }
1135  }
1136  if (attribute == null || !XmlConvert.ToBoolean(attribute))
1137  {
1138  return false;
1139  }
1140  return true;
1141  }
1142 
1145  protected string ReadNullableString()
1146  {
1147  if (ReadNull())
1148  {
1149  return null;
1150  }
1151  return r.ReadElementString();
1152  }
1153 
1157  {
1158  if (ReadNull())
1159  {
1160  return null;
1161  }
1162  return ReadElementQualifiedName();
1163  }
1164 
1168  {
1169  if (r.IsEmptyElement)
1170  {
1171  XmlQualifiedName result = new XmlQualifiedName(string.Empty, r.LookupNamespace(""));
1172  r.Skip();
1173  return result;
1174  }
1176  r.ReadEndElement();
1177  return result2;
1178  }
1179 
1184  protected XmlDocument ReadXmlDocument(bool wrapped)
1185  {
1186  XmlNode xmlNode = ReadXmlNode(wrapped);
1187  if (xmlNode == null)
1188  {
1189  return null;
1190  }
1191  XmlDocument xmlDocument = new XmlDocument();
1192  xmlDocument.AppendChild(xmlDocument.ImportNode(xmlNode, deep: true));
1193  return xmlDocument;
1194  }
1195 
1199  protected string CollapseWhitespace(string value)
1200  {
1201  return value?.Trim();
1202  }
1203 
1208  protected XmlNode ReadXmlNode(bool wrapped)
1209  {
1210  XmlNode result = null;
1211  if (wrapped)
1212  {
1213  if (ReadNull())
1214  {
1215  return null;
1216  }
1217  r.ReadStartElement();
1218  r.MoveToContent();
1219  if (r.NodeType != XmlNodeType.EndElement)
1220  {
1221  result = Document.ReadNode(r);
1222  }
1223  int whileIterations = 0;
1224  int readerCount = ReaderCount;
1225  while (r.NodeType != XmlNodeType.EndElement)
1226  {
1227  UnknownNode(null);
1228  CheckReaderCount(ref whileIterations, ref readerCount);
1229  }
1230  r.ReadEndElement();
1231  }
1232  else
1233  {
1234  result = Document.ReadNode(r);
1235  }
1236  return result;
1237  }
1238 
1242  protected static byte[] ToByteArrayBase64(string value)
1243  {
1244  return XmlCustomFormatter.ToByteArrayBase64(value);
1245  }
1246 
1251  protected byte[] ToByteArrayBase64(bool isNull)
1252  {
1253  if (isNull)
1254  {
1255  return null;
1256  }
1257  return ReadByteArray(isBase64: true);
1258  }
1259 
1263  protected static byte[] ToByteArrayHex(string value)
1264  {
1265  return XmlCustomFormatter.ToByteArrayHex(value);
1266  }
1267 
1272  protected byte[] ToByteArrayHex(bool isNull)
1273  {
1274  if (isNull)
1275  {
1276  return null;
1277  }
1278  return ReadByteArray(isBase64: false);
1279  }
1280 
1285  protected int GetArrayLength(string name, string ns)
1286  {
1287  if (GetNullAttr())
1288  {
1289  return 0;
1290  }
1291  string attribute = r.GetAttribute(arrayTypeID, soapNsID);
1292  SoapArrayInfo soapArrayInfo = ParseArrayType(attribute);
1293  if (soapArrayInfo.dimensions != 1)
1294  {
1295  throw new InvalidOperationException(Res.GetString("XmlInvalidArrayDimentions", CurrentTag()));
1296  }
1297  XmlQualifiedName xmlQualifiedName = ToXmlQualifiedName(soapArrayInfo.qname, decodeName: false);
1298  if (xmlQualifiedName.Name != name)
1299  {
1300  throw new InvalidOperationException(Res.GetString("XmlInvalidArrayTypeName", xmlQualifiedName.Name, name, CurrentTag()));
1301  }
1302  if (xmlQualifiedName.Namespace != ns)
1303  {
1304  throw new InvalidOperationException(Res.GetString("XmlInvalidArrayTypeNamespace", xmlQualifiedName.Namespace, ns, CurrentTag()));
1305  }
1306  return soapArrayInfo.length;
1307  }
1308 
1309  private SoapArrayInfo ParseArrayType(string value)
1310  {
1311  if (value == null)
1312  {
1313  throw new ArgumentNullException(Res.GetString("XmlMissingArrayType", CurrentTag()));
1314  }
1315  if (value.Length == 0)
1316  {
1317  throw new ArgumentException(Res.GetString("XmlEmptyArrayType", CurrentTag()), "value");
1318  }
1319  char[] array = value.ToCharArray();
1320  int num = array.Length;
1321  SoapArrayInfo result = default(SoapArrayInfo);
1322  int num2 = num - 1;
1323  if (array[num2] != ']')
1324  {
1325  throw new ArgumentException(Res.GetString("XmlInvalidArraySyntax"), "value");
1326  }
1327  num2--;
1328  while (num2 != -1 && array[num2] != '[')
1329  {
1330  if (array[num2] == ',')
1331  {
1332  throw new ArgumentException(Res.GetString("XmlInvalidArrayDimentions", CurrentTag()), "value");
1333  }
1334  num2--;
1335  }
1336  if (num2 == -1)
1337  {
1338  throw new ArgumentException(Res.GetString("XmlMismatchedArrayBrackets"), "value");
1339  }
1340  int num3 = num - num2 - 2;
1341  if (num3 > 0)
1342  {
1343  string text = new string(array, num2 + 1, num3);
1344  try
1345  {
1346  result.length = int.Parse(text, CultureInfo.InvariantCulture);
1347  }
1348  catch (Exception ex)
1349  {
1350  if (ex is ThreadAbortException || ex is StackOverflowException || ex is OutOfMemoryException)
1351  {
1352  throw;
1353  }
1354  throw new ArgumentException(Res.GetString("XmlInvalidArrayLength", text), "value");
1355  }
1356  }
1357  else
1358  {
1359  result.length = -1;
1360  }
1361  num2--;
1362  result.jaggedDimensions = 0;
1363  while (num2 != -1 && array[num2] == ']')
1364  {
1365  num2--;
1366  if (num2 < 0)
1367  {
1368  throw new ArgumentException(Res.GetString("XmlMismatchedArrayBrackets"), "value");
1369  }
1370  if (array[num2] == ',')
1371  {
1372  throw new ArgumentException(Res.GetString("XmlInvalidArrayDimentions", CurrentTag()), "value");
1373  }
1374  if (array[num2] != '[')
1375  {
1376  throw new ArgumentException(Res.GetString("XmlInvalidArraySyntax"), "value");
1377  }
1378  num2--;
1379  result.jaggedDimensions++;
1380  }
1381  result.dimensions = 1;
1382  result.qname = new string(array, 0, num2 + 1);
1383  return result;
1384  }
1385 
1386  private SoapArrayInfo ParseSoap12ArrayType(string itemType, string arraySize)
1387  {
1388  SoapArrayInfo soapArrayInfo = default(SoapArrayInfo);
1389  if (itemType != null && itemType.Length > 0)
1390  {
1391  soapArrayInfo.qname = itemType;
1392  }
1393  else
1394  {
1395  soapArrayInfo.qname = "";
1396  }
1397  string[] array = (arraySize == null || arraySize.Length <= 0) ? new string[0] : arraySize.Split(null);
1398  soapArrayInfo.dimensions = 0;
1399  soapArrayInfo.length = -1;
1400  for (int i = 0; i < array.Length; i++)
1401  {
1402  if (array[i].Length > 0)
1403  {
1404  if (array[i] == "*")
1405  {
1406  soapArrayInfo.dimensions++;
1407  }
1408  else
1409  {
1410  try
1411  {
1412  soapArrayInfo.length = int.Parse(array[i], CultureInfo.InvariantCulture);
1413  soapArrayInfo.dimensions++;
1414  }
1415  catch (Exception ex)
1416  {
1417  if (ex is ThreadAbortException || ex is StackOverflowException || ex is OutOfMemoryException)
1418  {
1419  throw;
1420  }
1421  throw new ArgumentException(Res.GetString("XmlInvalidArrayLength", array[i]), "value");
1422  }
1423  }
1424  }
1425  }
1426  if (soapArrayInfo.dimensions == 0)
1427  {
1428  soapArrayInfo.dimensions = 1;
1429  }
1430  return soapArrayInfo;
1431  }
1432 
1436  protected static DateTime ToDateTime(string value)
1437  {
1438  return XmlCustomFormatter.ToDateTime(value);
1439  }
1440 
1444  protected static DateTime ToDate(string value)
1445  {
1446  return XmlCustomFormatter.ToDate(value);
1447  }
1448 
1452  protected static DateTime ToTime(string value)
1453  {
1454  return XmlCustomFormatter.ToTime(value);
1455  }
1456 
1460  protected static char ToChar(string value)
1461  {
1462  return XmlCustomFormatter.ToChar(value);
1463  }
1464 
1470  protected static long ToEnum(string value, Hashtable h, string typeName)
1471  {
1472  return XmlCustomFormatter.ToEnum(value, h, typeName, validate: true);
1473  }
1474 
1478  protected static string ToXmlName(string value)
1479  {
1480  return XmlCustomFormatter.ToXmlName(value);
1481  }
1482 
1486  protected static string ToXmlNCName(string value)
1487  {
1488  return XmlCustomFormatter.ToXmlNCName(value);
1489  }
1490 
1494  protected static string ToXmlNmToken(string value)
1495  {
1496  return XmlCustomFormatter.ToXmlNmToken(value);
1497  }
1498 
1502  protected static string ToXmlNmTokens(string value)
1503  {
1504  return XmlCustomFormatter.ToXmlNmTokens(value);
1505  }
1506 
1510  protected XmlQualifiedName ToXmlQualifiedName(string value)
1511  {
1512  return ToXmlQualifiedName(value, DecodeName);
1513  }
1514 
1515  internal XmlQualifiedName ToXmlQualifiedName(string value, bool decodeName)
1516  {
1517  int num = value?.LastIndexOf(':') ?? (-1);
1518  string text = (num < 0) ? null : value.Substring(0, num);
1519  string text2 = value.Substring(num + 1);
1520  if (decodeName)
1521  {
1522  text = XmlConvert.DecodeName(text);
1523  text2 = XmlConvert.DecodeName(text2);
1524  }
1525  if (text == null || text.Length == 0)
1526  {
1527  return new XmlQualifiedName(r.NameTable.Add(value), r.LookupNamespace(string.Empty));
1528  }
1529  string text3 = r.LookupNamespace(text);
1530  if (text3 == null)
1531  {
1532  throw new InvalidOperationException(Res.GetString("XmlUndefinedAlias", text));
1533  }
1534  return new XmlQualifiedName(r.NameTable.Add(text2), text3);
1535  }
1536 
1540  protected void UnknownAttribute(object o, XmlAttribute attr)
1541  {
1542  UnknownAttribute(o, attr, null);
1543  }
1544 
1549  protected void UnknownAttribute(object o, XmlAttribute attr, string qnames)
1550  {
1551  if (events.OnUnknownAttribute != null)
1552  {
1553  GetCurrentPosition(out int lineNumber, out int linePosition);
1554  XmlAttributeEventArgs e = new XmlAttributeEventArgs(attr, lineNumber, linePosition, o, qnames);
1555  events.OnUnknownAttribute(events.sender, e);
1556  }
1557  }
1558 
1562  protected void UnknownElement(object o, XmlElement elem)
1563  {
1564  UnknownElement(o, elem, null);
1565  }
1566 
1571  protected void UnknownElement(object o, XmlElement elem, string qnames)
1572  {
1573  if (events.OnUnknownElement != null)
1574  {
1575  GetCurrentPosition(out int lineNumber, out int linePosition);
1576  XmlElementEventArgs e = new XmlElementEventArgs(elem, lineNumber, linePosition, o, qnames);
1577  events.OnUnknownElement(events.sender, e);
1578  }
1579  }
1580 
1583  protected void UnknownNode(object o)
1584  {
1585  UnknownNode(o, null);
1586  }
1587 
1591  protected void UnknownNode(object o, string qnames)
1592  {
1593  if (r.NodeType == XmlNodeType.None || r.NodeType == XmlNodeType.Whitespace)
1594  {
1595  r.Read();
1596  }
1597  else
1598  {
1599  if (r.NodeType == XmlNodeType.EndElement)
1600  {
1601  return;
1602  }
1603  if (events.OnUnknownNode != null)
1604  {
1605  UnknownNode(Document.ReadNode(r), o, qnames);
1606  }
1607  else if (r.NodeType != XmlNodeType.Attribute || events.OnUnknownAttribute != null)
1608  {
1609  if (r.NodeType == XmlNodeType.Element && events.OnUnknownElement == null)
1610  {
1611  r.Skip();
1612  }
1613  else
1614  {
1615  UnknownNode(Document.ReadNode(r), o, qnames);
1616  }
1617  }
1618  }
1619  }
1620 
1621  private void UnknownNode(XmlNode unknownNode, object o, string qnames)
1622  {
1623  if (unknownNode != null)
1624  {
1625  if (unknownNode.NodeType != 0 && unknownNode.NodeType != XmlNodeType.Whitespace && events.OnUnknownNode != null)
1626  {
1627  GetCurrentPosition(out int lineNumber, out int linePosition);
1628  XmlNodeEventArgs e = new XmlNodeEventArgs(unknownNode, lineNumber, linePosition, o);
1629  events.OnUnknownNode(events.sender, e);
1630  }
1631  if (unknownNode.NodeType == XmlNodeType.Attribute)
1632  {
1633  UnknownAttribute(o, (XmlAttribute)unknownNode, qnames);
1634  }
1635  else if (unknownNode.NodeType == XmlNodeType.Element)
1636  {
1637  UnknownElement(o, (XmlElement)unknownNode, qnames);
1638  }
1639  }
1640  }
1641 
1642  private void GetCurrentPosition(out int lineNumber, out int linePosition)
1643  {
1644  if (Reader is IXmlLineInfo)
1645  {
1646  IXmlLineInfo xmlLineInfo = (IXmlLineInfo)Reader;
1647  lineNumber = xmlLineInfo.LineNumber;
1648  linePosition = xmlLineInfo.LinePosition;
1649  }
1650  else
1651  {
1652  lineNumber = (linePosition = -1);
1653  }
1654  }
1655 
1659  protected void UnreferencedObject(string id, object o)
1660  {
1661  if (events.OnUnreferencedObject != null)
1662  {
1664  events.OnUnreferencedObject(events.sender, e);
1665  }
1666  }
1667 
1668  private string CurrentTag()
1669  {
1670  switch (r.NodeType)
1671  {
1672  case XmlNodeType.Element:
1673  return "<" + r.LocalName + " xmlns='" + r.NamespaceURI + "'>";
1674  case XmlNodeType.EndElement:
1675  return ">";
1676  case XmlNodeType.Text:
1677  return r.Value;
1678  case XmlNodeType.CDATA:
1679  return "CDATA";
1680  case XmlNodeType.Comment:
1681  return "<--";
1682  case XmlNodeType.ProcessingInstruction:
1683  return "<?";
1684  default:
1685  return "(unknown)";
1686  }
1687  }
1688 
1693  {
1694  return new InvalidOperationException(Res.GetString("XmlUnknownType", type.Name, type.Namespace, CurrentTag()));
1695  }
1696 
1701  {
1702  return new InvalidOperationException(Res.GetString("XmlReadOnlyCollection", name));
1703  }
1704 
1709  protected Exception CreateAbstractTypeException(string name, string ns)
1710  {
1711  return new InvalidOperationException(Res.GetString("XmlAbstractType", name, ns, CurrentTag()));
1712  }
1713 
1718  {
1719  return new InvalidOperationException(Res.GetString("XmlConstructorInaccessible", typeName));
1720  }
1721 
1725  protected Exception CreateCtorHasSecurityException(string typeName)
1726  {
1727  return new InvalidOperationException(Res.GetString("XmlConstructorHasSecurityAttributes", typeName));
1728  }
1729 
1733  {
1734  return new InvalidOperationException(Res.GetString("XmlUnknownNode", CurrentTag()));
1735  }
1736 
1741  protected Exception CreateUnknownConstantException(string value, Type enumType)
1742  {
1743  return new InvalidOperationException(Res.GetString("XmlUnknownConstant", value, enumType.Name));
1744  }
1745 
1750  protected Exception CreateInvalidCastException(Type type, object value)
1751  {
1752  return CreateInvalidCastException(type, value, null);
1753  }
1754 
1760  protected Exception CreateInvalidCastException(Type type, object value, string id)
1761  {
1762  if (value == null)
1763  {
1764  return new InvalidCastException(Res.GetString("XmlInvalidNullCast", type.FullName));
1765  }
1766  if (id == null)
1767  {
1768  return new InvalidCastException(Res.GetString("XmlInvalidCast", value.GetType().FullName, type.FullName));
1769  }
1770  return new InvalidCastException(Res.GetString("XmlInvalidCastWithId", value.GetType().FullName, type.FullName, id));
1771  }
1772 
1781  protected Exception CreateBadDerivationException(string xsdDerived, string nsDerived, string xsdBase, string nsBase, string clrDerived, string clrBase)
1782  {
1783  return new InvalidOperationException(Res.GetString("XmlSerializableBadDerivation", xsdDerived, nsDerived, xsdBase, nsBase, clrDerived, clrBase));
1784  }
1785 
1791  protected Exception CreateMissingIXmlSerializableType(string name, string ns, string clrType)
1792  {
1793  return new InvalidOperationException(Res.GetString("XmlSerializableMissingClrType", name, ns, typeof(XmlIncludeAttribute).Name, clrType));
1794  }
1795 
1801  protected Array EnsureArrayIndex(Array a, int index, Type elementType)
1802  {
1803  if (a == null)
1804  {
1805  return Array.CreateInstance(elementType, 32);
1806  }
1807  if (index < a.Length)
1808  {
1809  return a;
1810  }
1811  Array array = Array.CreateInstance(elementType, a.Length * 2);
1812  Array.Copy(a, array, index);
1813  return array;
1814  }
1815 
1823  protected Array ShrinkArray(Array a, int length, Type elementType, bool isNullable)
1824  {
1825  if (a == null)
1826  {
1827  if (isNullable)
1828  {
1829  return null;
1830  }
1831  return Array.CreateInstance(elementType, 0);
1832  }
1833  if (a.Length == length)
1834  {
1835  return a;
1836  }
1837  Array array = Array.CreateInstance(elementType, length);
1838  Array.Copy(a, array, length);
1839  return array;
1840  }
1841 
1845  protected string ReadString(string value)
1846  {
1847  return ReadString(value, trim: false);
1848  }
1849 
1855  protected string ReadString(string value, bool trim)
1856  {
1857  string text = r.ReadString();
1858  if (text != null && trim)
1859  {
1860  text = text.Trim();
1861  }
1862  if (value == null || value.Length == 0)
1863  {
1864  return text;
1865  }
1866  return value + text;
1867  }
1868 
1873  {
1874  return ReadSerializable(serializable, wrappedAny: false);
1875  }
1876 
1881  protected IXmlSerializable ReadSerializable(IXmlSerializable serializable, bool wrappedAny)
1882  {
1883  string b = null;
1884  string b2 = null;
1885  if (wrappedAny)
1886  {
1887  b = r.LocalName;
1888  b2 = r.NamespaceURI;
1889  r.Read();
1890  r.MoveToContent();
1891  }
1892  serializable.ReadXml(r);
1893  if (wrappedAny)
1894  {
1895  while (r.NodeType == XmlNodeType.Whitespace)
1896  {
1897  r.Skip();
1898  }
1899  if (r.NodeType == XmlNodeType.None)
1900  {
1901  r.Skip();
1902  }
1903  if (r.NodeType == XmlNodeType.EndElement && r.LocalName == b && r.NamespaceURI == b2)
1904  {
1905  Reader.Read();
1906  }
1907  }
1908  return serializable;
1909  }
1910 
1915  protected bool ReadReference(out string fixupReference)
1916  {
1917  string text = soap12 ? r.GetAttribute("ref", "http://www.w3.org/2003/05/soap-encoding") : r.GetAttribute("href");
1918  if (text == null)
1919  {
1920  fixupReference = null;
1921  return false;
1922  }
1923  if (!soap12)
1924  {
1925  if (!text.StartsWith("#", StringComparison.Ordinal))
1926  {
1927  throw new InvalidOperationException(Res.GetString("XmlMissingHref", text));
1928  }
1929  fixupReference = text.Substring(1);
1930  }
1931  else
1932  {
1933  fixupReference = text;
1934  }
1935  if (r.IsEmptyElement)
1936  {
1937  r.Skip();
1938  }
1939  else
1940  {
1941  r.ReadStartElement();
1942  ReadEndElement();
1943  }
1944  return true;
1945  }
1946 
1950  protected void AddTarget(string id, object o)
1951  {
1952  if (id == null)
1953  {
1954  if (targetsWithoutIds == null)
1955  {
1956  targetsWithoutIds = new ArrayList();
1957  }
1958  if (o != null)
1959  {
1960  targetsWithoutIds.Add(o);
1961  }
1962  }
1963  else
1964  {
1965  if (targets == null)
1966  {
1967  targets = new Hashtable();
1968  }
1969  if (!targets.Contains(id))
1970  {
1971  targets.Add(id, o);
1972  }
1973  }
1974  }
1975 
1978  protected void AddFixup(Fixup fixup)
1979  {
1980  if (fixups == null)
1981  {
1982  fixups = new ArrayList();
1983  }
1984  fixups.Add(fixup);
1985  }
1986 
1989  protected void AddFixup(CollectionFixup fixup)
1990  {
1991  if (collectionFixups == null)
1992  {
1993  collectionFixups = new ArrayList();
1994  }
1995  collectionFixups.Add(fixup);
1996  }
1997 
2001  protected object GetTarget(string id)
2002  {
2003  object obj = (targets != null) ? targets[id] : null;
2004  if (obj == null)
2005  {
2006  throw new InvalidOperationException(Res.GetString("XmlInvalidHref", id));
2007  }
2008  Referenced(obj);
2009  return obj;
2010  }
2011 
2014  protected void Referenced(object o)
2015  {
2016  if (o != null)
2017  {
2018  if (referencedTargets == null)
2019  {
2020  referencedTargets = new Hashtable();
2021  }
2022  referencedTargets[o] = o;
2023  }
2024  }
2025 
2026  private void HandleUnreferencedObjects()
2027  {
2028  if (targets != null)
2029  {
2030  foreach (DictionaryEntry target in targets)
2031  {
2032  if (referencedTargets == null || !referencedTargets.Contains(target.Value))
2033  {
2034  UnreferencedObject((string)target.Key, target.Value);
2035  }
2036  }
2037  }
2038  if (targetsWithoutIds != null)
2039  {
2040  foreach (object targetsWithoutId in targetsWithoutIds)
2041  {
2042  if (referencedTargets == null || !referencedTargets.Contains(targetsWithoutId))
2043  {
2044  UnreferencedObject(null, targetsWithoutId);
2045  }
2046  }
2047  }
2048  }
2049 
2050  private void DoFixups()
2051  {
2052  if (fixups == null)
2053  {
2054  return;
2055  }
2056  for (int i = 0; i < fixups.Count; i++)
2057  {
2058  Fixup fixup = (Fixup)fixups[i];
2059  fixup.Callback(fixup);
2060  }
2061  if (collectionFixups != null)
2062  {
2063  for (int j = 0; j < collectionFixups.Count; j++)
2064  {
2065  CollectionFixup collectionFixup = (CollectionFixup)collectionFixups[j];
2066  collectionFixup.Callback(collectionFixup.Collection, collectionFixup.CollectionItems);
2067  }
2068  }
2069  }
2070 
2073  protected void FixupArrayRefs(object fixup)
2074  {
2075  Fixup fixup2 = (Fixup)fixup;
2076  Array array = (Array)fixup2.Source;
2077  for (int i = 0; i < array.Length; i++)
2078  {
2079  string text = fixup2.Ids[i];
2080  if (text != null)
2081  {
2082  object target = GetTarget(text);
2083  try
2084  {
2085  array.SetValue(target, i);
2086  }
2087  catch (InvalidCastException)
2088  {
2089  throw new InvalidOperationException(Res.GetString("XmlInvalidArrayRef", text, target.GetType().FullName, i.ToString(CultureInfo.InvariantCulture)));
2090  }
2091  }
2092  }
2093  }
2094 
2095  private object ReadArray(string typeName, string typeNs)
2096  {
2097  Type type = null;
2098  SoapArrayInfo soapArrayInfo;
2099  if (soap12)
2100  {
2101  string attribute = r.GetAttribute(itemTypeID, soap12NsID);
2102  string attribute2 = r.GetAttribute(arraySizeID, soap12NsID);
2103  Type type2 = (Type)types[new XmlQualifiedName(typeName, typeNs)];
2104  if (attribute == null && attribute2 == null && (type2 == null || !type2.IsArray))
2105  {
2106  return null;
2107  }
2108  soapArrayInfo = ParseSoap12ArrayType(attribute, attribute2);
2109  if (type2 != null)
2110  {
2111  type = TypeScope.GetArrayElementType(type2, null);
2112  }
2113  }
2114  else
2115  {
2116  string attribute3 = r.GetAttribute(arrayTypeID, soapNsID);
2117  if (attribute3 == null)
2118  {
2119  return null;
2120  }
2121  soapArrayInfo = ParseArrayType(attribute3);
2122  }
2123  if (soapArrayInfo.dimensions != 1)
2124  {
2125  throw new InvalidOperationException(Res.GetString("XmlInvalidArrayDimentions", CurrentTag()));
2126  }
2127  Type type3 = null;
2128  XmlQualifiedName xmlQualifiedName = new XmlQualifiedName(urTypeID, schemaNsID);
2129  XmlQualifiedName xmlQualifiedName2;
2130  if (soapArrayInfo.qname.Length > 0)
2131  {
2132  xmlQualifiedName2 = ToXmlQualifiedName(soapArrayInfo.qname, decodeName: false);
2133  type3 = (Type)types[xmlQualifiedName2];
2134  }
2135  else
2136  {
2137  xmlQualifiedName2 = xmlQualifiedName;
2138  }
2139  if (soap12 && type3 == typeof(object))
2140  {
2141  type3 = null;
2142  }
2143  bool flag;
2144  if (type3 == null)
2145  {
2146  if (!soap12)
2147  {
2148  type3 = GetPrimitiveType(xmlQualifiedName2, throwOnUnknown: true);
2149  flag = true;
2150  }
2151  else
2152  {
2153  if (xmlQualifiedName2 != xmlQualifiedName)
2154  {
2155  type3 = GetPrimitiveType(xmlQualifiedName2, throwOnUnknown: false);
2156  }
2157  if (type3 != null)
2158  {
2159  flag = true;
2160  }
2161  else if (type == null)
2162  {
2163  type3 = typeof(object);
2164  flag = false;
2165  }
2166  else
2167  {
2168  type3 = type;
2169  XmlQualifiedName xmlQualifiedName3 = (XmlQualifiedName)typesReverse[type3];
2170  if (xmlQualifiedName3 == null)
2171  {
2172  xmlQualifiedName3 = XmlSerializationWriter.GetPrimitiveTypeNameInternal(type3);
2173  flag = true;
2174  }
2175  else
2176  {
2177  flag = type3.IsPrimitive;
2178  }
2179  if (xmlQualifiedName3 != null)
2180  {
2181  xmlQualifiedName2 = xmlQualifiedName3;
2182  }
2183  }
2184  }
2185  }
2186  else
2187  {
2188  flag = type3.IsPrimitive;
2189  }
2190  if (!soap12 && soapArrayInfo.jaggedDimensions > 0)
2191  {
2192  for (int i = 0; i < soapArrayInfo.jaggedDimensions; i++)
2193  {
2194  type3 = type3.MakeArrayType();
2195  }
2196  }
2197  if (r.IsEmptyElement)
2198  {
2199  r.Skip();
2200  return Array.CreateInstance(type3, 0);
2201  }
2202  r.ReadStartElement();
2203  r.MoveToContent();
2204  int num = 0;
2205  Array array = null;
2206  if (type3.IsValueType)
2207  {
2208  if (!flag && !type3.IsEnum)
2209  {
2210  throw new NotSupportedException(Res.GetString("XmlRpcArrayOfValueTypes", type3.FullName));
2211  }
2212  int whileIterations = 0;
2213  int readerCount = ReaderCount;
2214  while (r.NodeType != XmlNodeType.EndElement)
2215  {
2216  array = EnsureArrayIndex(array, num, type3);
2217  array.SetValue(ReadReferencedElement(xmlQualifiedName2.Name, xmlQualifiedName2.Namespace), num);
2218  num++;
2219  r.MoveToContent();
2220  CheckReaderCount(ref whileIterations, ref readerCount);
2221  }
2222  array = ShrinkArray(array, num, type3, isNullable: false);
2223  }
2224  else
2225  {
2226  string[] array2 = null;
2227  int num2 = 0;
2228  int whileIterations2 = 0;
2229  int readerCount2 = ReaderCount;
2230  while (r.NodeType != XmlNodeType.EndElement)
2231  {
2232  array = EnsureArrayIndex(array, num, type3);
2233  array2 = (string[])EnsureArrayIndex(array2, num2, typeof(string));
2234  string name;
2235  string ns;
2236  if (r.NamespaceURI.Length != 0)
2237  {
2238  name = r.LocalName;
2239  ns = (((object)r.NamespaceURI != soapNsID) ? r.NamespaceURI : "http://www.w3.org/2001/XMLSchema");
2240  }
2241  else
2242  {
2243  name = xmlQualifiedName2.Name;
2244  ns = xmlQualifiedName2.Namespace;
2245  }
2246  array.SetValue(ReadReferencingElement(name, ns, out array2[num2]), num);
2247  num++;
2248  num2++;
2249  r.MoveToContent();
2250  CheckReaderCount(ref whileIterations2, ref readerCount2);
2251  }
2252  if (soap12 && type3 == typeof(object))
2253  {
2254  Type type4 = null;
2255  for (int j = 0; j < num; j++)
2256  {
2257  object value = array.GetValue(j);
2258  if (value != null)
2259  {
2260  Type type5 = value.GetType();
2261  if (type5.IsValueType)
2262  {
2263  type4 = null;
2264  break;
2265  }
2266  if (type4 == null || type5.IsAssignableFrom(type4))
2267  {
2268  type4 = type5;
2269  }
2270  else if (!type4.IsAssignableFrom(type5))
2271  {
2272  type4 = null;
2273  break;
2274  }
2275  }
2276  }
2277  if (type4 != null)
2278  {
2279  type3 = type4;
2280  }
2281  }
2282  array2 = (string[])ShrinkArray(array2, num2, typeof(string), isNullable: false);
2283  array = ShrinkArray(array, num, type3, isNullable: false);
2284  Fixup fixup = new Fixup(array, FixupArrayRefs, array2);
2285  AddFixup(fixup);
2286  }
2287  ReadEndElement();
2288  return array;
2289  }
2290 
2292  protected abstract void InitCallbacks();
2293 
2295  protected void ReadReferencedElements()
2296  {
2297  r.MoveToContent();
2298  int whileIterations = 0;
2299  int readerCount = ReaderCount;
2300  while (r.NodeType != XmlNodeType.EndElement && r.NodeType != 0)
2301  {
2302  ReadReferencingElement(null, null, elementCanBeType: true, out string _);
2303  r.MoveToContent();
2304  CheckReaderCount(ref whileIterations, ref readerCount);
2305  }
2306  DoFixups();
2307  HandleUnreferencedObjects();
2308  }
2309 
2312  protected object ReadReferencedElement()
2313  {
2314  return ReadReferencedElement(null, null);
2315  }
2316 
2321  protected object ReadReferencedElement(string name, string ns)
2322  {
2323  string fixupReference;
2324  return ReadReferencingElement(name, ns, out fixupReference);
2325  }
2326 
2330  protected object ReadReferencingElement(out string fixupReference)
2331  {
2332  return ReadReferencingElement(null, null, out fixupReference);
2333  }
2334 
2340  protected object ReadReferencingElement(string name, string ns, out string fixupReference)
2341  {
2342  return ReadReferencingElement(name, ns, elementCanBeType: false, out fixupReference);
2343  }
2344 
2352  protected object ReadReferencingElement(string name, string ns, bool elementCanBeType, out string fixupReference)
2353  {
2354  object obj = null;
2355  if (callbacks == null)
2356  {
2357  callbacks = new Hashtable();
2358  types = new Hashtable();
2359  XmlQualifiedName xmlQualifiedName = new XmlQualifiedName(urTypeID, r.NameTable.Add("http://www.w3.org/2001/XMLSchema"));
2360  types.Add(xmlQualifiedName, typeof(object));
2361  typesReverse = new Hashtable();
2362  typesReverse.Add(typeof(object), xmlQualifiedName);
2363  InitCallbacks();
2364  }
2365  r.MoveToContent();
2366  if (ReadReference(out fixupReference))
2367  {
2368  return null;
2369  }
2370  if (ReadNull())
2371  {
2372  return null;
2373  }
2374  string id = soap12 ? r.GetAttribute("id", "http://www.w3.org/2003/05/soap-encoding") : r.GetAttribute("id", null);
2375  if ((obj = ReadArray(name, ns)) == null)
2376  {
2377  XmlQualifiedName xmlQualifiedName2 = GetXsiType();
2378  if (xmlQualifiedName2 == null)
2379  {
2380  xmlQualifiedName2 = ((name != null) ? new XmlQualifiedName(r.NameTable.Add(name), r.NameTable.Add(ns)) : new XmlQualifiedName(r.NameTable.Add(r.LocalName), r.NameTable.Add(r.NamespaceURI)));
2381  }
2382  XmlSerializationReadCallback xmlSerializationReadCallback = (XmlSerializationReadCallback)callbacks[xmlQualifiedName2];
2383  obj = ((xmlSerializationReadCallback == null) ? ReadTypedPrimitive(xmlQualifiedName2, elementCanBeType) : xmlSerializationReadCallback());
2384  }
2385  AddTarget(id, obj);
2386  return obj;
2387  }
2388 
2394  protected void AddReadCallback(string name, string ns, Type type, XmlSerializationReadCallback read)
2395  {
2396  XmlQualifiedName xmlQualifiedName = new XmlQualifiedName(r.NameTable.Add(name), r.NameTable.Add(ns));
2397  callbacks[xmlQualifiedName] = read;
2398  types[xmlQualifiedName] = type;
2399  typesReverse[type] = xmlQualifiedName;
2400  }
2401 
2403  protected void ReadEndElement()
2404  {
2405  while (r.NodeType == XmlNodeType.Whitespace)
2406  {
2407  r.Skip();
2408  }
2409  if (r.NodeType == XmlNodeType.None)
2410  {
2411  r.Skip();
2412  }
2413  else
2414  {
2415  r.ReadEndElement();
2416  }
2417  }
2418 
2419  private object ReadXmlNodes(bool elementCanBeType)
2420  {
2421  ArrayList arrayList = new ArrayList();
2422  string localName = Reader.LocalName;
2423  string namespaceURI = Reader.NamespaceURI;
2424  string name = Reader.Name;
2425  string text = null;
2426  string text2 = null;
2427  int num = 0;
2428  int lineNumber = -1;
2429  int linePosition = -1;
2430  XmlNode xmlNode = null;
2431  if (Reader.NodeType == XmlNodeType.Attribute)
2432  {
2433  XmlAttribute xmlAttribute = Document.CreateAttribute(name, namespaceURI);
2434  xmlAttribute.Value = Reader.Value;
2435  xmlNode = xmlAttribute;
2436  }
2437  else
2438  {
2439  xmlNode = Document.CreateElement(name, namespaceURI);
2440  }
2441  GetCurrentPosition(out lineNumber, out linePosition);
2442  XmlElement xmlElement = xmlNode as XmlElement;
2443  while (Reader.MoveToNextAttribute())
2444  {
2445  if (IsXmlnsAttribute(Reader.Name) || (Reader.Name == "id" && (!soap12 || Reader.NamespaceURI == "http://www.w3.org/2003/05/soap-encoding")))
2446  {
2447  num++;
2448  }
2449  if ((object)Reader.LocalName == typeID && ((object)Reader.NamespaceURI == instanceNsID || (object)Reader.NamespaceURI == instanceNs2000ID || (object)Reader.NamespaceURI == instanceNs1999ID))
2450  {
2451  string value = Reader.Value;
2452  int num2 = value.LastIndexOf(':');
2453  text = ((num2 >= 0) ? value.Substring(num2 + 1) : value);
2454  text2 = Reader.LookupNamespace((num2 >= 0) ? value.Substring(0, num2) : "");
2455  }
2456  XmlAttribute xmlAttribute2 = (XmlAttribute)Document.ReadNode(r);
2457  arrayList.Add(xmlAttribute2);
2458  xmlElement?.SetAttributeNode(xmlAttribute2);
2459  }
2460  if (elementCanBeType && text == null)
2461  {
2462  text = localName;
2463  text2 = namespaceURI;
2464  XmlAttribute xmlAttribute3 = Document.CreateAttribute(typeID, instanceNsID);
2465  xmlAttribute3.Value = name;
2466  arrayList.Add(xmlAttribute3);
2467  }
2468  if (text == "anyType" && ((object)text2 == schemaNsID || (object)text2 == schemaNs1999ID || (object)text2 == schemaNs2000ID))
2469  {
2470  num++;
2471  }
2473  if (Reader.IsEmptyElement)
2474  {
2475  Reader.Skip();
2476  }
2477  else
2478  {
2481  int whileIterations = 0;
2482  int readerCount = ReaderCount;
2483  while (Reader.NodeType != XmlNodeType.EndElement)
2484  {
2485  XmlNode xmlNode2 = Document.ReadNode(r);
2486  arrayList.Add(xmlNode2);
2487  xmlElement?.AppendChild(xmlNode2);
2489  CheckReaderCount(ref whileIterations, ref readerCount);
2490  }
2491  ReadEndElement();
2492  }
2493  if (arrayList.Count <= num)
2494  {
2495  return new object();
2496  }
2497  XmlNode[] result = (XmlNode[])arrayList.ToArray(typeof(XmlNode));
2498  UnknownNode(xmlNode, null, null);
2499  return result;
2500  }
2501 
2506  protected void CheckReaderCount(ref int whileIterations, ref int readerCount)
2507  {
2508  if (!checkDeserializeAdvances)
2509  {
2510  return;
2511  }
2512  whileIterations++;
2513  if ((whileIterations & 0x80) == 128)
2514  {
2515  if (readerCount == ReaderCount)
2516  {
2517  throw new InvalidOperationException(Res.GetString("XmlInternalErrorReaderAdvance"));
2518  }
2519  readerCount = ReaderCount;
2520  }
2521  }
2522  }
2523 }
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
Definition: CultureInfo.cs:263
bool IsPrimitive
Gets a value indicating whether the T:System.Type is one of the primitive types.
Definition: Type.cs:690
abstract string BaseURI
When overridden in a derived class, gets the base URI of the current node.
Definition: XmlReader.cs:215
Allows the T:System.Xml.Serialization.XmlSerializer to recognize a type when it serializes or deseria...
bool GetNullAttr()
Determines whether the XML element where the T:System.Xml.XmlReader is currently positioned has a nul...
void Referenced(object o)
Stores an object to be deserialized from a SOAP-encoded multiRef element.
Represents an XML document. You can use this class to load, validate, edit, add, and position XML in ...
Definition: XmlDocument.cs:13
void AddFixup(CollectionFixup fixup)
Stores an object that contains a callback method that will be called, as necessary,...
void AddFixup(Fixup fixup)
Stores an object that contains a callback method instance that will be called, as necessary,...
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
abstract string LookupNamespace(string prefix)
When overridden in a derived class, resolves a namespace prefix in the current element's scope.
static DateTime ToDate(string value)
Produces a T:System.DateTime object from an input string.
Exception CreateUnknownNodeException()
Creates an T:System.InvalidOperationException that indicates that the current position of T:System....
virtual void Add(object key, object value)
Adds an element with the specified key and value into the T:System.Collections.Hashtable.
Definition: Hashtable.cs:916
object ReadReferencingElement(string name, string ns, out string fixupReference)
Deserializes an object from an XML element in a SOAP message that contains a reference to a multiRef ...
Array ShrinkArray(Array a, int length, Type elementType, bool isNullable)
Ensures that a given array, or a copy, is no larger than a specified length.
object ReadTypedPrimitive(XmlQualifiedName type)
Gets the value of the XML node at which the T:System.Xml.XmlReader is currently positioned.
static DateTime ToTime(string value)
Produces a T:System.DateTime from a string that represents the time.
abstract bool MoveToElement()
When overridden in a derived class, moves to the element that contains the current attribute node.
void UnknownNode(object o, string qnames)
Raises an E:System.Xml.Serialization.XmlSerializer.UnknownNode event for the current position of the ...
void ReadReferencedElements()
Deserializes objects from the SOAP-encoded multiRef elements in a SOAP message.
abstract string LocalName
When overridden in a derived class, gets the local name of the current node.
Definition: XmlReader.cs:133
abstract string FullName
Gets the fully qualified name of the type, including its namespace but not its assembly.
Definition: Type.cs:153
void CheckReaderCount(ref int whileIterations, ref int readerCount)
Checks whether the deserializer has advanced.
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
Exception CreateBadDerivationException(string xsdDerived, string nsDerived, string xsdBase, string nsBase, string clrDerived, string clrBase)
Populates an object from its XML representation at the current location of the T:System....
IXmlSerializable ReadSerializable(IXmlSerializable serializable, bool wrappedAny)
This method supports the .NET Framework infrastructure and is not intended to be used directly from y...
void UnknownAttribute(object o, XmlAttribute attr)
Raises an E:System.Xml.Serialization.XmlSerializer.UnknownAttribute event for the current position of...
virtual void Skip()
Skips the children of the current node.
Definition: XmlReader.cs:1159
void FixupArrayRefs(object fixup)
Fills in the values of a SOAP-encoded array whose data type maps to a .NET Framework reference type.
XmlElement CreateElement(string name)
Creates an element with the specified name.
Definition: XmlDocument.cs:847
XmlSerializationFixupCallback Callback
Gets the callback method that creates an instance of the T:System.Xml.Serialization....
int GetArrayLength(string name, string ns)
Gets the length of the SOAP-encoded array where the T:System.Xml.XmlReader is currently positioned.
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2255
Definition: __Canon.cs:3
Provides data for the E:System.Xml.Serialization.XmlSerializer.UnknownNode event.
abstract void InitCallbacks()
Initializes callback methods that populate objects that map to SOAP-encoded XML data.
virtual XmlNode ReadNode(XmlReader reader)
Creates an T:System.Xml.XmlNode object based on the information in the T:System.Xml....
static Assembly ResolveDynamicAssembly(string assemblyFullName)
Gets a dynamically generated assembly by name.
The exception that is thrown for invalid casting or explicit conversion.
Represents an attribute. Valid and default values for the attribute are defined in a document type de...
Definition: XmlAttribute.cs:7
int ReaderCount
Gets the current count of the T:System.Xml.XmlReader.
Exception CreateAbstractTypeException(string name, string ns)
Creates an T:System.InvalidOperationException that indicates that an object being deserialized should...
static DateTime ToDateTime(string value)
Produces a T:System.DateTime object from an input string.
abstract string NamespaceURI
When overridden in a derived class, gets the namespace URI (as defined in the W3C Namespace specifica...
Definition: XmlReader.cs:143
virtual XmlNodeType MoveToContent()
Checks whether the current node is a content (non-white space text, CDATA, Element,...
Definition: XmlReader.cs:1311
void UnknownNode(object o)
Raises an E:System.Xml.Serialization.XmlSerializer.UnknownNode event for the current position of the ...
static string DecodeName(string name)
Decodes a name. This method does the reverse of the M:System.Xml.XmlConvert.EncodeName(System....
Definition: XmlConvert.cs:81
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
Definition: DateTime.cs:13
static string ToXmlName(string value)
Decodes an XML name.
XmlNodeType
Specifies the type of node.
Definition: XmlNodeType.cs:5
XmlDocument Document
Gets the XML document object into which the XML document is being deserialized.
object ReadReferencingElement(string name, string ns, bool elementCanBeType, out string fixupReference)
Deserializes an object from an XML element in a SOAP message that contains a reference to a multiRef ...
string Namespace
Gets a string representation of the namespace of the T:System.Xml.XmlQualifiedName.
XmlQualifiedName GetXsiType()
Gets the value of the xsi:type attribute for the XML element at the current location of the T:System....
bool DecodeName
Gets or sets a value that determines whether XML strings are translated into valid ....
Array EnsureArrayIndex(Array a, int index, Type elementType)
Ensures that a given array, or a copy, is large enough to contain a specified index.
abstract XmlNodeType NodeType
When overridden in a derived class, gets the type of the current node.
Definition: XmlReader.cs:94
Exception CreateUnknownTypeException(XmlQualifiedName type)
Creates an T:System.InvalidOperationException that indicates that a type is unknown.
Controls deserialization by the T:System.Xml.Serialization.XmlSerializer class.
void UnreferencedObject(string id, object o)
Raises an E:System.Xml.Serialization.XmlSerializer.UnreferencedObject event for the current position ...
static string ToXmlNCName(string value)
Decodes an XML name.
XmlNode ReadXmlNode(bool wrapped)
Instructs the T:System.Xml.XmlReader to read the XML node at its current position.
Represents a reader that provides fast, noncached, forward-only access to XML data....
Definition: XmlReader.cs:15
virtual XmlNode ImportNode(XmlNode node, bool deep)
Imports a node from another document to the current document.
override string NamespaceURI
Gets the namespace URI of this node.
Definition: XmlAttribute.cs:41
XmlSerializationCollectionFixupCallback Callback
Gets the callback method that instantiates the T:System.Xml.Serialization.XmlSerializationCollectionF...
virtual int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
Reads the element and decodes the BinHex content.
Definition: XmlReader.cs:1245
object ReadReferencedElement(string name, string ns)
Deserializes an object from a SOAP-encoded multiRef XML element.
byte [] ToByteArrayHex(bool isNull)
Instructs the T:System.Xml.XmlReader to read the string value at its current position and return it a...
bool IsArray
Gets a value that indicates whether the type is an array.
Definition: Type.cs:551
object Collection
Gets the object collection for the callback method.
string Name
Gets a string representation of the qualified name of the T:System.Xml.XmlQualifiedName.
virtual string Name
When overridden in a derived class, gets the qualified name of the current node.
Definition: XmlReader.cs:116
static long ToEnum(string value, Hashtable h, string typeName)
Produces a numeric enumeration value from a string that consists of delimited identifiers that repres...
static byte [] ToByteArrayBase64(string value)
Produces a base-64 byte array from an input string.
void UnknownElement(object o, XmlElement elem, string qnames)
Raises an E:System.Xml.Serialization.XmlSerializer.UnknownElement event for the current position of t...
Exception CreateUnknownConstantException(string value, Type enumType)
Creates an T:System.InvalidOperationException that indicates that an enumeration value is not valid.
Exception CreateReadOnlyCollectionException(string name)
Creates an T:System.InvalidOperationException that indicates that a SOAP-encoded collection type cann...
Represents a collection of key/value pairs that are organized based on the hash code of the key....
Definition: Hashtable.cs:17
virtual void ReadEndElement()
Checks that the current content node is an end tag and advances the reader to the next node.
Definition: XmlReader.cs:1500
byte [] ToByteArrayBase64(bool isNull)
Instructs the T:System.Xml.XmlReader to read the string value at its current position and return it a...
void ReadXml(XmlReader reader)
Generates an object from its XML representation.
Provides data for the E:System.Xml.Serialization.XmlSerializer.UnknownElement event.
string ReadString(string value)
Produces the result of a call to the M:System.Xml.XmlReader.ReadString method appended to the input v...
abstract void InitIDs()
Stores element and attribute names in a T:System.Xml.NameTable object.
Handles the XML elements used to configure XML serialization.
Represents an assembly, which is a reusable, versionable, and self-describing building block of a com...
Definition: Assembly.cs:22
Fixup(object o, XmlSerializationFixupCallback callback, string[] ids)
Initializes a new instance of the T:System.Xml.Serialization.XmlSerializationReader....
Exception CreateInvalidCastException(Type type, object value)
Creates an T:System.InvalidCastException that indicates that an explicit reference conversion failed.
virtual int ReadElementContentAsBase64(byte[] buffer, int index, int count)
Reads the element and decodes the Base64 content.
Definition: XmlReader.cs:1210
void AddTarget(string id, object o)
Stores an object that is being deserialized from a SOAP-encoded multiRef element for later access thr...
bool IsXmlnsAttribute(string name)
Determines whether an XML attribute name indicates an XML namespace.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition: Array.cs:17
Represents an element.
Definition: XmlElement.cs:7
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
static char ToChar(string value)
Produces a T:System.Char object from an input string.
bool IsReturnValue
Gets or sets a value that should be true for a SOAP 1.1 return value.
XmlAttribute CreateAttribute(string name)
Creates an T:System.Xml.XmlAttribute with the specified P:System.Xml.XmlDocument.Name.
Definition: XmlDocument.cs:786
Represents an XML qualified name.
abstract string Name
Gets the name of the current member.
Definition: MemberInfo.cs:27
DateTime IConvertible. ToDateTime(IFormatProvider provider)
Returns the current T:System.DateTime object.
Definition: DateTime.cs:1931
XmlReader Reader
Gets the T:System.Xml.XmlReader object that is being used by T:System.Xml.Serialization....
object ReadTypedNull(XmlQualifiedName type)
Reads an XML element that allows null values (xsi:nil = 'true') and returns a generic T:System....
object CollectionItems
Gets the array into which the callback method copies a collection.
object GetTarget(string id)
Gets an object that is being deserialized from a SOAP-encoded multiRef element and that was stored ea...
abstract bool MoveToNextAttribute()
When overridden in a derived class, moves to the next attribute.
delegate object XmlSerializationReadCallback()
Delegate used by the T:System.Xml.Serialization.XmlSerializer class for deserialization of types from...
string ReadString(string value, bool trim)
Returns the result of a call to the M:System.Xml.XmlReader.ReadString method of the T:System....
virtual int Add(object value)
Adds an object to the end of the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2381
object Source
Gets or sets the object that contains other objects whose values get filled in by the callback implem...
abstract string GetAttribute(string name)
When overridden in a derived class, gets the value of the attribute with the specified P:System....
Exception CreateInaccessibleConstructorException(string typeName)
Creates an T:System.InvalidOperationException that indicates that an object being deserialized cannot...
XmlQualifiedName ToXmlQualifiedName(string value)
Obtains an T:System.Xml.XmlQualifiedName from a name that may contain a prefix.
void ReadEndElement()
Makes the T:System.Xml.XmlReader read an XML end tag.
The exception that is thrown when one of the arguments provided to a method is not valid.
override string LocalName
Gets the local name of the node.
Definition: XmlAttribute.cs:37
abstract bool Read()
When overridden in a derived class, reads the next node from the stream.
delegate void XmlSerializationFixupCallback(object fixup)
Delegate used by the T:System.Xml.Serialization.XmlSerializer class for deserialization of SOAP-encod...
XmlQualifiedName ReadNullableQualifiedName()
Instructs the T:System.Xml.XmlReader to read the fully qualified name of the element where it is curr...
object ReadReferencingElement(out string fixupReference)
Deserializes an object from an XML element in a SOAP message that contains a reference to a multiRef ...
virtual void ReadStartElement()
Checks that the current node is an element and advances the reader to the next node.
Definition: XmlReader.cs:1340
string [] Ids
Gets or sets an array of keys for the objects that belong to the P:System.Xml.Serialization....
virtual string ReadElementString()
Reads a text-only element. However, we recommend that you use the M:System.Xml.XmlReader....
Definition: XmlReader.cs:1397
bool ReadNull()
Instructs the T:System.Xml.XmlReader to read the current XML element if the element has a null attrib...
Holds an T:System.Xml.Serialization.XmlSerializationCollectionFixupCallback delegate instance,...
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
Definition: Array.cs:1275
static string ToXmlNmTokens(string value)
Decodes an XML name.
string ReadNullableString()
Instructs the T:System.Xml.XmlReader to read a simple, text-only XML element that could be null.
string CollapseWhitespace(string value)
Removes all occurrences of white space characters from the beginning and end of the specified string.
virtual bool Contains(object key)
Determines whether the T:System.Collections.Hashtable contains a specific key.
Definition: Hashtable.cs:972
abstract string Add(char[] array, int offset, int length)
When overridden in a derived class, atomizes the specified string and adds it to the XmlNameTable.
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
Definition: Exception.cs:22
Provides data for the E:System.Xml.Serialization.XmlSerializer.UnknownAttribute event.
object Value
Gets or sets the value in the key/value pair.
Holds an T:System.Xml.Serialization.XmlSerializationFixupCallback delegate instance,...
Exception CreateCtorHasSecurityException(string typeName)
Creates an T:System.InvalidOperationException that indicates that an object being deserialized cannot...
static bool ToBoolean(string s)
Converts the T:System.String to a T:System.Boolean equivalent.
Definition: XmlConvert.cs:837
abstract bool IsEmptyElement
When overridden in a derived class, gets a value indicating whether the current node is an empty elem...
Definition: XmlReader.cs:226
virtual string ReadString()
When overridden in a derived class, reads the contents of an element or text node as a string....
Definition: XmlReader.cs:1272
int Length
Gets the total number of elements in all the dimensions of the T:System.Array.
Definition: Array.cs:829
static string ToXmlNmToken(string value)
Decodes an XML name.
IXmlSerializable ReadSerializable(IXmlSerializable serializable)
Populates an object from its XML representation at the current location of the T:System....
CollectionFixup(object collection, XmlSerializationCollectionFixupCallback callback, object collectionItems)
Initializes a new instance of the T:System.Xml.Serialization.XmlSerializationReader....
virtual XmlNode AppendChild(XmlNode newChild)
Adds the specified node to the end of the list of child nodes, of this node.
Definition: XmlNode.cs:833
void UnknownElement(object o, XmlElement elem)
Raises an E:System.Xml.Serialization.XmlSerializer.UnknownElement event for the current position of t...
Fixup(object o, XmlSerializationFixupCallback callback, int count)
Initializes a new instance of the T:System.Xml.Serialization.XmlSerializationReader....
The exception that is thrown when a method call is invalid for the object's current state.
XmlDocument ReadXmlDocument(bool wrapped)
Instructs the T:System.Xml.XmlReader to read an XML document root element at its current position.
XmlQualifiedName ReadElementQualifiedName()
Makes the T:System.Xml.XmlReader read the fully qualified name of the element where it is currently p...
object Key
Gets or sets the key in the key/value pair.
Provides data for the known, but unreferenced, object found in an encoded SOAP XML stream during dese...
void UnknownAttribute(object o, XmlAttribute attr, string qnames)
Raises an E:System.Xml.Serialization.XmlSerializer.UnknownAttribute event for the current position of...
object ReadReferencedElement()
Deserializes an object from a SOAP-encoded multiRef XML element.
void AddReadCallback(string name, string ns, Type type, XmlSerializationReadCallback read)
Stores an implementation of the T:System.Xml.Serialization.XmlSerializationReadCallback delegate and ...
Contains fields that can be used to pass event delegates to a thread-safe Overload:System....
bool ReadReference(out string fixupReference)
Reads the value of the href attribute (ref attribute for SOAP 1.2) that is used to refer to an XML el...
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
static byte [] ToByteArrayHex(string value)
Produces a hexadecimal byte array from an input string.
override string Value
Gets or sets the value of the node.
Definition: XmlAttribute.cs:71
abstract string Value
When overridden in a derived class, gets the text value of the current node.
Definition: XmlReader.cs:195
The exception that is thrown when a call is made to the M:System.Threading.Thread....
An abstract class that is the base class for T:System.Xml.Serialization.XmlSerializationReader and T:...
Defines a dictionary key/value pair that can be set or retrieved.
void ParseWsdlArrayType(XmlAttribute attr)
Sets the value of the XML attribute if it is of type arrayType from the Web Services Description Lang...
Provides custom formatting for XML serialization and deserialization.
Represents a single node in the XML document.
Definition: XmlNode.cs:13
delegate void XmlSerializationCollectionFixupCallback(object collection, object collectionItems)
Delegate used by the T:System.Xml.Serialization.XmlSerializer class for deserialization of SOAP-encod...
abstract XmlNodeType NodeType
Gets the type of the current node, when overridden in a derived class.
Definition: XmlNode.cs:53
static unsafe Array CreateInstance(Type elementType, int length)
Creates a one-dimensional T:System.Array of the specified T:System.Type and length,...
Definition: Array.cs:972
Exception CreateMissingIXmlSerializableType(string name, string ns, string clrType)
Creates an T:System.InvalidOperationException that indicates that a derived type that is mapped to an...
abstract XmlNameTable NameTable
When overridden in a derived class, gets the T:System.Xml.XmlNameTable associated with this implement...
Definition: XmlReader.cs:373
virtual object [] ToArray()
Copies the elements of the T:System.Collections.ArrayList to a new T:System.Object array.
Definition: ArrayList.cs:3083
Encodes and decodes XML names, and provides methods for converting between common language runtime ty...
Definition: XmlConvert.cs:11
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
Definition: ArrayList.cs:14
Exception CreateInvalidCastException(Type type, object value, string id)
Creates an T:System.InvalidCastException that indicates that an explicit reference conversion failed.