Merge pull request #347 from JamesB7/master
[mono.git] / mcs / class / System.XML / Mono.Xml / XmlFilterReader.cs
old mode 100755 (executable)
new mode 100644 (file)
index c2648b3..2449438
@@ -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
-       public class XmlFilterReader : XmlReader, IXmlLineInfo\r
+       internal class XmlFilterReader : XmlReader, IXmlLineInfo, IXmlNamespaceResolver\r
        {\r
                XmlReader reader;\r
                XmlReaderSettings settings;\r
@@ -45,11 +47,22 @@ 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
                #region Properties\r
+\r
+#if NET_2_0\r
+               public override bool CanReadBinaryContent {\r
+                       get { return reader.CanReadBinaryContent; }\r
+               }\r
+\r
+               public override bool CanReadValueChunk {\r
+                       get { return reader.CanReadValueChunk; }\r
+               }\r
+#endif\r
+\r
                // This is the only one non-overriden property.\r
                public XmlReader Reader {\r
                        get { return reader; }\r
@@ -147,6 +160,16 @@ namespace Mono.Xml
                public override XmlNameTable NameTable {\r
                        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
+               }\r
                #endregion\r
 \r
                #region Methods\r
@@ -203,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
@@ -232,16 +256,6 @@ namespace Mono.Xml
                        return reader.ReadString ();\r
                }\r
 \r
-               public override string ReadInnerXml ()\r
-               {\r
-                       return reader.ReadInnerXml ();\r
-               }\r
-\r
-               public override string ReadOuterXml ()\r
-               {\r
-                       return reader.ReadOuterXml ();\r
-               }\r
-\r
                public override string LookupNamespace (string prefix)\r
                {\r
                        return reader.LookupNamespace (prefix);\r
@@ -255,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