Merge pull request #347 from JamesB7/master
[mono.git] / mcs / class / System.XML / Mono.Xml / XmlFilterReader.cs
index 412d6f18a574635b6acf9ea50c449ed816367915..24494382abaffc61f64d2edb01e42388bbc0af4b 100644 (file)
@@ -5,26 +5,26 @@
 //     Atsushi Enomoto <atsushi@ximian.com>\r
 //\r
 // Copyright (c) 2004 Novell Inc. All rights reserved\r
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
 \r
 //\r
 // Similar to SAX DefaultHandler\r
 \r
 #if NET_2_0\r
 using System;\r
+using System.Collections.Generic;\r
 using System.Xml;\r
 using System.Xml.Schema;\r
 \r
 namespace Mono.Xml\r
 {\r
-       internal class XmlFilterReader : XmlReader, IXmlLineInfo\r
+       internal class XmlFilterReader : XmlReader, IXmlLineInfo, IXmlNamespaceResolver\r
        {\r
                XmlReader reader;\r
                XmlReaderSettings settings;\r
@@ -46,7 +47,7 @@ namespace Mono.Xml
                public XmlFilterReader (XmlReader reader, XmlReaderSettings settings)\r
                {\r
                        this.reader = reader;\r
-                       this.settings = settings;\r
+                       this.settings = settings.Clone ();\r
                        this.lineInfo = reader as IXmlLineInfo;\r
                }\r
 \r
@@ -160,9 +161,11 @@ namespace Mono.Xml
                        get { return reader.NameTable; }\r
                }\r
 \r
+#if !NET_2_1\r
                public override IXmlSchemaInfo SchemaInfo {\r
                        get { return reader.SchemaInfo; }\r
                }\r
+#endif\r
 \r
                public override XmlReaderSettings Settings {\r
                        get { return settings; }\r
@@ -223,7 +226,8 @@ namespace Mono.Xml
 \r
                public override void Close ()\r
                {\r
-                       reader.Close ();\r
+                       if (settings.CloseInput)\r
+                               reader.Close ();\r
                }\r
 \r
                public override bool Read ()\r
@@ -252,19 +256,6 @@ namespace Mono.Xml
                        return reader.ReadString ();\r
                }\r
 \r
-#if NET_1_1\r
-#else\r
-               public override string ReadInnerXml ()\r
-               {\r
-                       return ReadInnerXmlInternal ();\r
-               }\r
-\r
-               public override string ReadOuterXml ()\r
-               {\r
-                       return ReadOuterXmlInternal ();\r
-               }\r
-#endif\r
-\r
                public override string LookupNamespace (string prefix)\r
                {\r
                        return reader.LookupNamespace (prefix);\r
@@ -278,6 +269,17 @@ namespace Mono.Xml
                public override bool ReadAttributeValue () {\r
                        return reader.ReadAttributeValue ();\r
                }\r
+\r
+               string IXmlNamespaceResolver.LookupPrefix (string ns)\r
+               {\r
+                       return ((IXmlNamespaceResolver) reader).LookupPrefix (ns);\r
+               }\r
+\r
+               IDictionary<string, string> IXmlNamespaceResolver.GetNamespacesInScope (XmlNamespaceScope scope)\r
+               {\r
+                       return ((IXmlNamespaceResolver) reader).GetNamespacesInScope (scope);\r
+               }\r
+\r
                #endregion\r
        }\r
 }\r