File: XmlAsyncCheckReader.cs

package info (click to toggle)
mono 6.8.0.105%2Bdfsg-3.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,284,512 kB
  • sloc: cs: 11,172,132; xml: 2,850,069; ansic: 671,653; cpp: 122,091; perl: 59,366; javascript: 30,841; asm: 22,168; makefile: 20,093; sh: 15,020; python: 4,827; pascal: 925; sql: 859; sed: 16; php: 1
file content (922 lines) | stat: -rw-r--r-- 28,828 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922

using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Xml.Schema;

namespace System.Xml {

    internal class XmlAsyncCheckReader : XmlReader {

        private readonly XmlReader coreReader = null;
        private Task lastTask = AsyncHelper.DoneTask;

        internal XmlReader CoreReader {
            get {
                return coreReader;
            }
        }

        public static XmlAsyncCheckReader CreateAsyncCheckWrapper(XmlReader reader)
        {
            if (reader is IXmlLineInfo) {
                if (reader is IXmlNamespaceResolver) {
#if !FEATURE_NETCORE
                    if (reader is IXmlSchemaInfo) {
                        return new XmlAsyncCheckReaderWithLineInfoNSSchema(reader);
                    }
#endif // !FEATURE_NETCORE
                    return new XmlAsyncCheckReaderWithLineInfoNS(reader);
                }
#if !FEATURE_NETCORE
                Debug.Assert(!(reader is IXmlSchemaInfo));
#endif // !FEATURE_NETCORE
                return new XmlAsyncCheckReaderWithLineInfo(reader);
            }
            else if (reader is IXmlNamespaceResolver) {
#if !FEATURE_NETCORE
                Debug.Assert(!(reader is IXmlSchemaInfo));
#endif // !FEATURE_NETCORE
                return new XmlAsyncCheckReaderWithNS(reader);
            }
#if !FEATURE_NETCORE
            Debug.Assert(!(reader is IXmlSchemaInfo));
#endif // !FEATURE_NETCORE
            return new XmlAsyncCheckReader(reader);
        }

        public XmlAsyncCheckReader(XmlReader reader) {
            coreReader = reader;
        }

        private void CheckAsync() {
            if (!lastTask.IsCompleted) {
                throw new InvalidOperationException(Res.GetString(Res.Xml_AsyncIsRunningException));
            }
        }

        #region Sync Methods, Properties Check
        
        public override XmlReaderSettings Settings {
            get {
                XmlReaderSettings settings = coreReader.Settings;
                if (null != settings) {
                    settings = settings.Clone();
                }
                else {
                    settings = new XmlReaderSettings();
                }
                settings.Async = true;
                settings.ReadOnly = true;
                return settings;
            }
        }
        
        public override XmlNodeType NodeType {
            get {
                CheckAsync();
                return coreReader.NodeType;
            }
        }
        
        public override string Name {
            get {
                CheckAsync();
                return coreReader.Name;
            }
        }
        
        public override string LocalName {
            get {
                CheckAsync();
                return coreReader.LocalName;
            }
        }
        
        public override string NamespaceURI {
            get {
                CheckAsync();
                return coreReader.NamespaceURI;
            }
        }
        
        public override string Prefix {
            get {
                CheckAsync();
                return coreReader.Prefix;
            }
        }
        
        public override bool HasValue {
            get {
                CheckAsync();
                return coreReader.HasValue;
            }
        }
        
        public override string Value {
            get {
                CheckAsync();
                return coreReader.Value;
            }
        }
        
        public override int Depth {
            get {
                CheckAsync();
                return coreReader.Depth;
            }
        }
        
        public override string BaseURI {
            get {
                CheckAsync();
                return coreReader.BaseURI;
            }
        }
        
        public override bool IsEmptyElement {
            get {
                CheckAsync();
                return coreReader.IsEmptyElement;
            }
        }
        
        public override bool IsDefault {
            get {
                CheckAsync();
                return coreReader.IsDefault;
            }
        }
        
#if !SILVERLIGHT
        public override char QuoteChar {
            get {
                CheckAsync();
                return coreReader.QuoteChar;
            }
        }
#endif // !SILVERLIGHT
        
        public override XmlSpace XmlSpace {
            get {
                CheckAsync();
                return coreReader.XmlSpace;
            }
        }
        
        public override string XmlLang {
            get {
                CheckAsync();
                return coreReader.XmlLang;
            }
        }
        
#if !FEATURE_NETCORE
        public override IXmlSchemaInfo SchemaInfo {
            get {
                CheckAsync();
                return coreReader.SchemaInfo;
            }
        }
#endif // !FEATURE_NETCORE
        
        public override System.Type ValueType {
            get {
                CheckAsync();
                return coreReader.ValueType;
            }
        }
        
        public override object ReadContentAsObject() {
            CheckAsync();
            return coreReader.ReadContentAsObject();
        }
        
        public override bool ReadContentAsBoolean() {
            CheckAsync();
            return coreReader.ReadContentAsBoolean();
        }
        
        public override DateTime ReadContentAsDateTime() {
            CheckAsync();
            return coreReader.ReadContentAsDateTime();
        }
        
        public override double ReadContentAsDouble() {
            CheckAsync();
            return coreReader.ReadContentAsDouble();
        }
        
        public override float ReadContentAsFloat() {
            CheckAsync();
            return coreReader.ReadContentAsFloat();
        }
        
        public override decimal ReadContentAsDecimal() {
            CheckAsync();
            return coreReader.ReadContentAsDecimal();
        }
        
        public override int ReadContentAsInt() {
            CheckAsync();
            return coreReader.ReadContentAsInt();
        }
        
        public override long ReadContentAsLong() {
            CheckAsync();
            return coreReader.ReadContentAsLong();
        }
        
        public override string ReadContentAsString() {
            CheckAsync();
            return coreReader.ReadContentAsString();
        }
        
        public override object ReadContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) {
            CheckAsync();
            return coreReader.ReadContentAs(returnType, namespaceResolver);
        }
        
        public override object ReadElementContentAsObject() {
            CheckAsync();
            return coreReader.ReadElementContentAsObject();
        }
        
        public override object ReadElementContentAsObject(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadElementContentAsObject(localName, namespaceURI);
        }
        
        public override bool ReadElementContentAsBoolean() {
            CheckAsync();
            return coreReader.ReadElementContentAsBoolean();
        }
        
        public override bool ReadElementContentAsBoolean(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadElementContentAsBoolean(localName, namespaceURI);
        }
        
        public override DateTime ReadElementContentAsDateTime() {
            CheckAsync();
            return coreReader.ReadElementContentAsDateTime();
        }
        
        public override DateTime ReadElementContentAsDateTime(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadElementContentAsDateTime(localName, namespaceURI);
        }

        public override DateTimeOffset ReadContentAsDateTimeOffset() {
            CheckAsync();
            return coreReader.ReadContentAsDateTimeOffset();
        }
        
        public override double ReadElementContentAsDouble() {
            CheckAsync();
            return coreReader.ReadElementContentAsDouble();
        }
        
        public override double ReadElementContentAsDouble(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadElementContentAsDouble(localName, namespaceURI);
        }
        
        public override float ReadElementContentAsFloat() {
            CheckAsync();
            return coreReader.ReadElementContentAsFloat();
        }
        
        public override float ReadElementContentAsFloat(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadElementContentAsFloat(localName, namespaceURI);
        }
        
        public override decimal ReadElementContentAsDecimal() {
            CheckAsync();
            return coreReader.ReadElementContentAsDecimal();
        }
        
        public override decimal ReadElementContentAsDecimal(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadElementContentAsDecimal(localName, namespaceURI);
        }
        
        public override int ReadElementContentAsInt() {
            CheckAsync();
            return coreReader.ReadElementContentAsInt();
        }
        
        public override int ReadElementContentAsInt(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadElementContentAsInt(localName, namespaceURI);
        }
        
        public override long ReadElementContentAsLong() {
            CheckAsync();
            return coreReader.ReadElementContentAsLong();
        }
        
        public override long ReadElementContentAsLong(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadElementContentAsLong(localName, namespaceURI);
        }
        
        public override string ReadElementContentAsString() {
            CheckAsync();
            return coreReader.ReadElementContentAsString();
        }
        
        public override string ReadElementContentAsString(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadElementContentAsString(localName, namespaceURI);
        }
        
        public override object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) {
            CheckAsync();
            return coreReader.ReadElementContentAs(returnType, namespaceResolver);
        }
        
        public override object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver, string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadElementContentAs(returnType, namespaceResolver, localName, namespaceURI);
        }
        
        public override int AttributeCount {
            get {
                CheckAsync();
                return coreReader.AttributeCount;
            }
        }
        
        public override string GetAttribute(string name) {
            CheckAsync();
            return coreReader.GetAttribute(name);
        }
        
        public override string GetAttribute(string name, string namespaceURI) {
            CheckAsync();
            return coreReader.GetAttribute(name, namespaceURI);
        }
        
        public override string GetAttribute(int i) {
            CheckAsync();
            return coreReader.GetAttribute(i);
        }

        public override string this[int i] {
            get {
                CheckAsync();
                return coreReader[i];
            }
        }

        public override string this[string name] {
            get {
                CheckAsync();
                return coreReader[name];
            }
        }

        public override string this[string name, string namespaceURI] {
            get {
                CheckAsync();
                return coreReader[name, namespaceURI];
            }
        }
        
        public override bool MoveToAttribute(string name) {
            CheckAsync();
            return coreReader.MoveToAttribute(name);
        }
        
        public override bool MoveToAttribute(string name, string ns) {
            CheckAsync();
            return coreReader.MoveToAttribute(name, ns);
        }
        
        public override void MoveToAttribute(int i) {
            CheckAsync();
            coreReader.MoveToAttribute(i);
        }
        
        public override bool MoveToFirstAttribute() {
            CheckAsync();
            return coreReader.MoveToFirstAttribute();
        }
        
        public override bool MoveToNextAttribute() {
            CheckAsync();
            return coreReader.MoveToNextAttribute();
        }
        
        public override bool MoveToElement() {
            CheckAsync();
            return coreReader.MoveToElement();
        }
        
        public override bool ReadAttributeValue() {
            CheckAsync();
            return coreReader.ReadAttributeValue();
        }
        
        public override bool Read() {
            CheckAsync();
            return coreReader.Read();
        }
        
        public override bool EOF {
            get {
                CheckAsync();
                return coreReader.EOF;
            }
        }
        
        public override void Close() {
            CheckAsync();
            coreReader.Close();
        }
        
        public override ReadState ReadState {
            get {
                CheckAsync();
                return coreReader.ReadState;
            }
        }
        
        public override void Skip() {
            CheckAsync();
            coreReader.Skip();
        }
        
        public override XmlNameTable NameTable {
            get {
                CheckAsync();
                return coreReader.NameTable;
            }
        }
        
        public override string LookupNamespace(string prefix) {
            CheckAsync();
            return coreReader.LookupNamespace(prefix);
        }
        
        public override bool CanResolveEntity {
            get {
                CheckAsync();
                return coreReader.CanResolveEntity;
            }
        }
        
        public override void ResolveEntity() {
            CheckAsync();
            coreReader.ResolveEntity();
        }
        
        public override bool CanReadBinaryContent {
            get {
                CheckAsync();
                return coreReader.CanReadBinaryContent;
            }
        }
        
        public override int ReadContentAsBase64(byte[] buffer, int index, int count) {
            CheckAsync();
            return coreReader.ReadContentAsBase64(buffer, index, count);
        }
        
        public override int ReadElementContentAsBase64(byte[] buffer, int index, int count) {
            CheckAsync();
            return coreReader.ReadElementContentAsBase64(buffer, index, count);
        }
        
        public override int ReadContentAsBinHex(byte[] buffer, int index, int count) {
            CheckAsync();
            return coreReader.ReadContentAsBinHex(buffer, index, count);
        }
        
        public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) {
            CheckAsync();
            return coreReader.ReadElementContentAsBinHex(buffer, index, count);
        }
        
        public override bool CanReadValueChunk {
            get {
                CheckAsync();
                return coreReader.CanReadValueChunk;
            }
        }
        
        public override int ReadValueChunk(char[] buffer, int index, int count) {
            CheckAsync();
            return coreReader.ReadValueChunk(buffer, index, count);
        }
        
#if !SILVERLIGHT
        public override string ReadString() {
            CheckAsync();
            return coreReader.ReadString();
        }
#endif // !SILVERLIGHT
        
        public override XmlNodeType MoveToContent() {
            CheckAsync();
            return coreReader.MoveToContent();
        }
        
        public override void ReadStartElement() {
            CheckAsync();
            coreReader.ReadStartElement();
        }
        
        public override void ReadStartElement(string name) {
            CheckAsync();
            coreReader.ReadStartElement(name);
        }
        
        public override void ReadStartElement(string localname, string ns) {
            CheckAsync();
            coreReader.ReadStartElement(localname, ns);
        }
        
#if !SILVERLIGHT
        public override string ReadElementString() {
            CheckAsync();
            return coreReader.ReadElementString();
        }
        
        public override string ReadElementString(string name) {
            CheckAsync();
            return coreReader.ReadElementString(name);
        }
        
        public override string ReadElementString(string localname, string ns) {
            CheckAsync();
            return coreReader.ReadElementString(localname, ns);
        }
#endif // !SILVERLIGHT
        
        public override void ReadEndElement() {
            CheckAsync();
            coreReader.ReadEndElement();
        }
        
        public override bool IsStartElement() {
            CheckAsync();
            return coreReader.IsStartElement();
        }
        
        public override bool IsStartElement(string name) {
            CheckAsync();
            return coreReader.IsStartElement(name);
        }
        
        public override bool IsStartElement(string localname, string ns) {
            CheckAsync();
            return coreReader.IsStartElement(localname, ns);
        }
        
        public override bool ReadToFollowing(string name) {
            CheckAsync();
            return coreReader.ReadToFollowing(name);
        }
        
        public override bool ReadToFollowing(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadToFollowing(localName, namespaceURI);
        }
        
        public override bool ReadToDescendant(string name) {
            CheckAsync();
            return coreReader.ReadToDescendant(name);
        }
        
        public override bool ReadToDescendant(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadToDescendant(localName, namespaceURI);
        }
        
        public override bool ReadToNextSibling(string name) {
            CheckAsync();
            return coreReader.ReadToNextSibling(name);
        }
        
        public override bool ReadToNextSibling(string localName, string namespaceURI) {
            CheckAsync();
            return coreReader.ReadToNextSibling(localName, namespaceURI);
        }
        
        public override string ReadInnerXml() {
            CheckAsync();
            return coreReader.ReadInnerXml();
        }
        
        public override string ReadOuterXml() {
            CheckAsync();
            return coreReader.ReadOuterXml();
        }
        
        public override XmlReader ReadSubtree() {
            CheckAsync();
            XmlReader subtreeReader = coreReader.ReadSubtree();
            return CreateAsyncCheckWrapper(subtreeReader);
        }
        
        public override bool HasAttributes {
            get {
                CheckAsync();
                return coreReader.HasAttributes;
            }
        }

        protected override void Dispose(bool disposing) {
            CheckAsync();
            //since it is protected method, we can't call coreReader.Dispose(disposing). 
            //Internal, it is always called to Dipose(true). So call coreReader.Dispose() is OK.
            coreReader.Dispose();
        }

#if !SILVERLIGHT
        internal override XmlNamespaceManager NamespaceManager {
            get {
                CheckAsync();
                return coreReader.NamespaceManager;
            }
        }

        internal override IDtdInfo DtdInfo {
            get {
                CheckAsync();
                return coreReader.DtdInfo;
            }
        }
#endif

        #endregion

        #region Async Methods
        
        public override Task<string> GetValueAsync() {
            CheckAsync();
            var task = coreReader.GetValueAsync();
            lastTask = task;
            return task;
        }
        
        public override Task<object> ReadContentAsObjectAsync() {
            CheckAsync();
            var task = coreReader.ReadContentAsObjectAsync();
            lastTask = task;
            return task;
        }
        
        public override Task<string> ReadContentAsStringAsync() {
            CheckAsync();
            var task = coreReader.ReadContentAsStringAsync();
            lastTask = task;
            return task;
        }
        
        public override Task<object> ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) {
            CheckAsync();
            var task = coreReader.ReadContentAsAsync(returnType, namespaceResolver);
            lastTask = task;
            return task;
        }
        
        public override Task<object> ReadElementContentAsObjectAsync() {
            CheckAsync();
            var task = coreReader.ReadElementContentAsObjectAsync();
            lastTask = task;
            return task;
        }
        
        public override Task<string> ReadElementContentAsStringAsync() {
            CheckAsync();
            var task = coreReader.ReadElementContentAsStringAsync();
            lastTask = task;
            return task;
        }
        
        public override Task<object> ReadElementContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) {
            CheckAsync();
            var task = coreReader.ReadElementContentAsAsync(returnType, namespaceResolver);
            lastTask = task;
            return task;
        }
        
        public override Task<bool> ReadAsync() {
            CheckAsync();
            var task = coreReader.ReadAsync();
            lastTask = task;
            return task;
        }
        
        public override Task SkipAsync() {
            CheckAsync();
            var task = coreReader.SkipAsync();
            lastTask = task;
            return task;
        }
        
        public override Task<int> ReadContentAsBase64Async(byte[] buffer, int index, int count) {
            CheckAsync();
            var task = coreReader.ReadContentAsBase64Async(buffer, index, count);
            lastTask = task;
            return task;
        }
        
        public override Task<int> ReadElementContentAsBase64Async(byte[] buffer, int index, int count) {
            CheckAsync();
            var task = coreReader.ReadElementContentAsBase64Async(buffer, index, count);
            lastTask = task;
            return task;
        }
        
        public override Task<int> ReadContentAsBinHexAsync(byte[] buffer, int index, int count) {
            CheckAsync();
            var task = coreReader.ReadContentAsBinHexAsync(buffer, index, count);
            lastTask = task;
            return task;
        }
        
        public override Task<int> ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count) {
            CheckAsync();
            var task = coreReader.ReadElementContentAsBinHexAsync(buffer, index, count);
            lastTask = task;
            return task;
        }
        
        public override Task<int> ReadValueChunkAsync(char[] buffer, int index, int count) {
            CheckAsync();
            var task = coreReader.ReadValueChunkAsync(buffer, index, count);
            lastTask = task;
            return task;
        }
        
        public override Task<XmlNodeType> MoveToContentAsync() {
            CheckAsync();
            var task = coreReader.MoveToContentAsync();
            lastTask = task;
            return task;
        }
      
        public override Task<string> ReadInnerXmlAsync() {
            CheckAsync();
            var task = coreReader.ReadInnerXmlAsync();
            lastTask = task;
            return task;
        }
        
        public override Task<string> ReadOuterXmlAsync() {
            CheckAsync();
            var task = coreReader.ReadOuterXmlAsync();
            lastTask = task;
            return task;
        }

        #endregion

    }

    internal class XmlAsyncCheckReaderWithNS : XmlAsyncCheckReader, IXmlNamespaceResolver {
        private readonly IXmlNamespaceResolver readerAsIXmlNamespaceResolver;

        public XmlAsyncCheckReaderWithNS(XmlReader reader)
            : base(reader) {

            readerAsIXmlNamespaceResolver = (IXmlNamespaceResolver)reader;
        }

        #region IXmlNamespaceResolver members
        IDictionary<string, string> IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope)
        {
            return readerAsIXmlNamespaceResolver.GetNamespacesInScope(scope);
        }

        string IXmlNamespaceResolver.LookupNamespace(string prefix)
        {
            return readerAsIXmlNamespaceResolver.LookupNamespace(prefix);
        }

        string IXmlNamespaceResolver.LookupPrefix(string namespaceName)
        {
            return readerAsIXmlNamespaceResolver.LookupPrefix(namespaceName);
        }
        #endregion
    }

    internal class XmlAsyncCheckReaderWithLineInfo : XmlAsyncCheckReader, IXmlLineInfo {

        private readonly IXmlLineInfo readerAsIXmlLineInfo;

        public XmlAsyncCheckReaderWithLineInfo(XmlReader reader)
            : base(reader) {

            readerAsIXmlLineInfo = (IXmlLineInfo)reader;
        }

        #region IXmlLineInfo members
        public virtual bool HasLineInfo() {
            return readerAsIXmlLineInfo.HasLineInfo();
        }

        public virtual int LineNumber {
            get {
                return readerAsIXmlLineInfo.LineNumber;
            }
        }

        public virtual int LinePosition {
            get {
                return readerAsIXmlLineInfo.LinePosition;
            }
        }
        #endregion
    }

    internal class XmlAsyncCheckReaderWithLineInfoNS : XmlAsyncCheckReaderWithLineInfo, IXmlNamespaceResolver {

        private readonly IXmlNamespaceResolver readerAsIXmlNamespaceResolver;

        public XmlAsyncCheckReaderWithLineInfoNS(XmlReader reader)
            : base(reader) {

            readerAsIXmlNamespaceResolver = (IXmlNamespaceResolver)reader;
        }

        #region IXmlNamespaceResolver members
        IDictionary<string, string> IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope) {
            return readerAsIXmlNamespaceResolver.GetNamespacesInScope(scope);
        }

        string IXmlNamespaceResolver.LookupNamespace(string prefix) {
            return readerAsIXmlNamespaceResolver.LookupNamespace(prefix);
        }

        string IXmlNamespaceResolver.LookupPrefix(string namespaceName) {
            return readerAsIXmlNamespaceResolver.LookupPrefix(namespaceName);
        }
        #endregion
    }

#if !FEATURE_NETCORE
    internal class XmlAsyncCheckReaderWithLineInfoNSSchema : XmlAsyncCheckReaderWithLineInfoNS, IXmlSchemaInfo {

        private readonly IXmlSchemaInfo readerAsIXmlSchemaInfo;

        public XmlAsyncCheckReaderWithLineInfoNSSchema(XmlReader reader)
            : base(reader) {

            readerAsIXmlSchemaInfo = (IXmlSchemaInfo)reader;
        }


        #region IXmlSchemaInfo members

        XmlSchemaValidity IXmlSchemaInfo.Validity {
            get {
                return readerAsIXmlSchemaInfo.Validity;
            }
        }

        bool IXmlSchemaInfo.IsDefault {
            get {
                return readerAsIXmlSchemaInfo.IsDefault;
            }
        }

        bool IXmlSchemaInfo.IsNil {
            get {
                return readerAsIXmlSchemaInfo.IsNil;
            }
        }

        XmlSchemaSimpleType IXmlSchemaInfo.MemberType {
            get {
                return readerAsIXmlSchemaInfo.MemberType;
            }
        }

        XmlSchemaType IXmlSchemaInfo.SchemaType {
            get {
                return readerAsIXmlSchemaInfo.SchemaType;
            }
        }

        XmlSchemaElement IXmlSchemaInfo.SchemaElement {
            get {
                return readerAsIXmlSchemaInfo.SchemaElement;
            }
        }

        XmlSchemaAttribute IXmlSchemaInfo.SchemaAttribute {
            get {
                return readerAsIXmlSchemaInfo.SchemaAttribute;
            }
        }
        #endregion
    }
#endif // !FEATURE_NETCORE
}