Sfoglia il codice sorgente

2009-08-01 Miguel de Icaza <[email protected]>

	* Various changes to support the non-XAP XmlSchema resolution on
	the Moonlight build.    

	Major missing feature: WebRequest resolution.

svn path=/trunk/mcs/; revision=139246
Miguel de Icaza 16 anni fa
parent
commit
3fc2ac11bc

+ 7 - 0
mcs/class/System.XML/ChangeLog

@@ -1,3 +1,10 @@
+2009-08-01  Miguel de Icaza  <[email protected]>
+
+	* Various changes to support the non-XAP XmlSchema resolution on
+	the Moonlight build.    
+
+	Major missing feature: WebRequest resolution.
+
 2009-04-28  Sebastien Pouliot  <[email protected]> 
 
 	* net_2_1_raw_System.Xml.dll.sources: Remove XmlUrlResolver.cs 

+ 4 - 0
mcs/class/System.XML/System.Xml.Schema/XmlSchemaException.cs

@@ -113,10 +113,12 @@ namespace System.Xml.Schema
 				innerException)
 		{
 			hasLineInfo = true;
+#if !MONOTOUCH
 			this.lineNumber = sourceObject.LineNumber;
 			this.linePosition = sourceObject.LinePosition;
 			this.sourceObj	=	sourceObject;
 			this.sourceUri	=	sourceObject.SourceUri;
+#endif
 		}
 
 		public XmlSchemaException(string message, Exception innerException)
@@ -161,9 +163,11 @@ namespace System.Xml.Schema
 					(sourceUri != null && sourceUri != "") ? "URI: " + sourceUri + " ." : "",
 					lineNumber,
 					linePosition);
+#if !MONOTOUCH
 			if (sourceObj != null)
 				msg += String.Format (CultureInfo.InvariantCulture, " Related schema item SourceUri: {0}, Line {1}, Position {2}.",
 					sourceObj.SourceUri, sourceObj.LineNumber, sourceObj.LinePosition);
+#endif
 			return msg;
 		}
 

+ 1 - 1
mcs/class/System.XML/System.Xml.Schema/XmlSchemaSet_2_1.cs

@@ -32,7 +32,7 @@ namespace System.Xml.Schema {
 
 	public class XmlSchemaSet {
 
-		private XmlSchemaSet ()
+		internal XmlSchemaSet ()
 		{
 		}
 	}

+ 84 - 0
mcs/class/System.XML/System.Xml/XmlUrlResolverMonoTouch.cs

@@ -0,0 +1,84 @@
+// System.Xml.XmlUrlResolver.cs
+//
+// Author: Duncan Mak ([email protected])
+//	   Atsushi Enomoto ([email protected])
+//
+// (C) Ximian, Inc.
+//
+
+//
+// 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.
+//
+
+using System.Net;
+using System.IO;
+using System.Text;
+
+namespace System.Xml
+{
+	public class XmlUrlResolver : XmlResolver
+	{
+		// Constructor
+		public XmlUrlResolver ()
+			: base ()
+		{
+		}
+
+		// Methods
+		public override object GetEntity (Uri absoluteUri, string role, Type ofObjectToReturn)
+		{
+			if (ofObjectToReturn == null)
+				ofObjectToReturn = typeof (Stream);
+			if (ofObjectToReturn != typeof (Stream))
+				throw new XmlException ("This object type is not supported.");
+
+			if (!absoluteUri.IsAbsoluteUri)
+				throw new ArgumentException ("uri must be absolute.", "absoluteUri");
+
+			if (absoluteUri.Scheme == "file") {
+				if (absoluteUri.AbsolutePath == String.Empty)
+					throw new ArgumentException ("uri must be absolute.", "absoluteUri");
+				return new FileStream (UnescapeRelativeUriBody (absoluteUri.LocalPath), FileMode.Open, FileAccess.Read, FileShare.Read);
+			}
+
+			// (MS documentation says) parameter role isn't used yet.
+			//WebRequest req = WebRequest.Create (absoluteUri);
+			//return req.GetResponse().GetResponseStream();
+
+			return "";
+		}
+
+		public override Uri ResolveUri (Uri baseUri, string relativeUri)
+		{
+			return base.ResolveUri (baseUri, relativeUri);
+		}
+
+		// see also XmlResolver.EscapeRelativeUriBody().
+		private string UnescapeRelativeUriBody (string src)
+		{
+			return src.Replace ("%3C", "<")
+				.Replace ("%3E", ">")
+				.Replace ("%23", "#")
+				.Replace ("%22", "\"")
+				.Replace ("%20", " ")
+				.Replace ("%25", "%");
+		}
+	}
+}

+ 7 - 0
mcs/class/System.XML/monotouch_System.Xml.dll.sources

@@ -1 +1,8 @@
 #include net_2_1_raw_System.Xml.dll.sources
+System.Xml.Schema/XmlSchemaValidationFlags.cs 
+System.Xml/ValidationType.cs
+System.Xml.Schema/ValidationEventArgs.cs
+System.Xml.Schema/XmlSchemaException.cs
+System.Xml.Schema/ValidationHandler.cs
+System.Xml/XmlUrlResolverMonoTouch.cs
+