internal static XmlReader CreateXmlReader(Stream stream, Encoding encoding) { Debug.Assert(null != stream, "null stream"); XmlReaderSettings settings = new XmlReaderSettings(); settings.CheckCharacters = false; #if ASTORIA_CLIENT settings.CloseInput = true; #endif settings.IgnoreWhitespace = true; settings.NameTable = XmlUtil.CreateAtomNameTable(); if (null == encoding) { return(XmlReader.Create(stream, settings)); } return(XmlReader.Create(new StreamReader(stream, encoding), settings)); }
internal static XmlReader CreateXmlReader(Stream stream, Encoding encoding) { Debug.Assert(null != stream, "null stream"); XmlReaderSettings settings = new XmlReaderSettings(); settings.CheckCharacters = false; #if ASTORIA_CLIENT // we should close the underlying stream only for the client. // In server, we should never close the underlying stream - neither after reading nor after writing, // since the underlying host owns the stream. settings.CloseInput = true; #endif settings.IgnoreWhitespace = true; settings.NameTable = XmlUtil.CreateAtomNameTable(); if (null == encoding) { // auto-detect the encoding return(XmlReader.Create(stream, settings)); } return(XmlReader.Create(new StreamReader(stream, encoding), settings)); }