XmlValidatingReader for arbitrary XmlReaders: I had a dream...
Note: this entry has moved.
Every now and then, I face this really bothering bug, which
is that even when the
XmlValidatingReader accepts an
XmlReader in its constructor, it will actually
throw a run-time exception if it receives anything other
than an XmlTextReader
The constructor is the one to blame, as Reflector shows up-front:
public XmlValidatingReader(XmlReader reader)
{
this._PartialContentNodeType = 0;
base..ctor();
this._CoreReader = (reader as XmlTextReader);
if (this._CoreReader == null)
{
throw new ArgumentException("reader");
}
And the exception isn't too helpful either, right? Damn.... now I'm trying to layer rules validation in the middle of the XmlReader and the XmlValidatingReader and I'm starting to think I'm out of luck... :S
Oleg mentioned this some time ago too. :(