Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Baulig <martin.baulig@googlemail.com>2012-06-03 03:43:52 +0400
committerMartin Baulig <martin.baulig@googlemail.com>2012-06-03 06:02:28 +0400
commit78873611b2dfc0ca27f64e9639e4460d50c0380c (patch)
treefc53b0c57f9a27d6853f1905602e59d96b48c2b5 /mcs/class/System.XML/System.Xml
parent7d170f400d288f240cf231f481bad67a9e352b0c (diff)
More .NET 4.5 work.
Diffstat (limited to 'mcs/class/System.XML/System.Xml')
-rw-r--r--mcs/class/System.XML/System.Xml/XmlReader.cs15
-rw-r--r--mcs/class/System.XML/System.Xml/XmlResolver.cs18
-rw-r--r--mcs/class/System.XML/System.Xml/XmlSecureResolver.cs19
-rw-r--r--mcs/class/System.XML/System.Xml/XmlTextReader2.cs2
-rw-r--r--mcs/class/System.XML/System.Xml/XmlUrlResolver.cs55
5 files changed, 108 insertions, 1 deletions
diff --git a/mcs/class/System.XML/System.Xml/XmlReader.cs b/mcs/class/System.XML/System.Xml/XmlReader.cs
index 07d734f80b2..f09046f59cf 100644
--- a/mcs/class/System.XML/System.Xml/XmlReader.cs
+++ b/mcs/class/System.XML/System.Xml/XmlReader.cs
@@ -240,7 +240,15 @@ namespace System.Xml
#region Methods
+#if NET_4_5
+ public virtual void Close ()
+ {
+ if (asyncRunning)
+ throw new InvalidOperationException ("An asynchronous operation is already in progress.");
+ }
+#else
public abstract void Close ();
+#endif
#if NET_2_0
private static XmlNameTable PopulateNameTable (
@@ -988,6 +996,13 @@ namespace System.Xml
return ReadContentAs (ValueType, null);
}
+#if NET_4_5
+ public virtual DateTimeOffset ReadContentAsDateTimeOffset ()
+ {
+ return XmlConvert.ToDateTimeOffset (ReadContentString ());
+ }
+#endif
+
public virtual object ReadElementContentAs (Type returnType, IXmlNamespaceResolver namespaceResolver)
{
bool isEmpty = IsEmptyElement;
diff --git a/mcs/class/System.XML/System.Xml/XmlResolver.cs b/mcs/class/System.XML/System.Xml/XmlResolver.cs
index 8949225d3bb..f51f71f7662 100644
--- a/mcs/class/System.XML/System.Xml/XmlResolver.cs
+++ b/mcs/class/System.XML/System.Xml/XmlResolver.cs
@@ -33,14 +33,23 @@
using System.IO;
using System.Net;
using System.Security.Permissions;
+#if NET_4_5
+using System.Threading.Tasks;
+#endif
namespace System.Xml
{
public abstract class XmlResolver
{
#if !MOONLIGHT
+#if NET_4_5
+ public virtual ICredentials Credentials {
+ set { throw new NotImplementedException (); }
+ }
+#else
public abstract ICredentials Credentials { set; }
#endif
+#endif
public abstract object GetEntity (Uri absoluteUri, string role, Type ofObjectToReturn);
@@ -77,7 +86,7 @@ namespace System.Xml
.Replace ("%", "%25")
.Replace ("\"", "%22");
}
-#if MOONLIGHT
+#if MOONLIGHT || NET_4_5
public virtual bool SupportsType (Uri absoluteUri, Type type)
{
if (absoluteUri == null)
@@ -85,5 +94,12 @@ namespace System.Xml
return ((type == null) || (type == typeof (Stream)));
}
#endif
+
+#if NET_4_5
+ public virtual Task<object> GetEntityAsync (Uri absoluteUri, string role, Type ofObjectToReturn)
+ {
+ return Task.Run (() => GetEntity (absoluteUri, role, ofObjectToReturn));
+ }
+#endif
}
}
diff --git a/mcs/class/System.XML/System.Xml/XmlSecureResolver.cs b/mcs/class/System.XML/System.Xml/XmlSecureResolver.cs
index 2260d81a0bd..61547c3efab 100644
--- a/mcs/class/System.XML/System.Xml/XmlSecureResolver.cs
+++ b/mcs/class/System.XML/System.Xml/XmlSecureResolver.cs
@@ -32,6 +32,9 @@ using System.Net;
using System.Security;
using System.Security.Policy;
using System.Security.Permissions;
+#if NET_4_5
+using System.Threading.Tasks;
+#endif
namespace System.Xml
{
@@ -131,6 +134,22 @@ namespace System.Xml
{
return resolver.ResolveUri (baseUri, relativeUri);
}
+
+#if NET_4_5
+ public override async Task<object> GetEntityAsync (
+ Uri absoluteUri, string role, Type ofObjectToReturn)
+ {
+ if (SecurityManager.SecurityEnabled) {
+ // in case the security manager was switched after the constructor was called
+ if (permissionSet == null) {
+ throw new SecurityException (Locale.GetText (
+ "Security Manager wasn't active when instance was created."));
+ }
+ permissionSet.PermitOnly ();
+ }
+ return await resolver.GetEntityAsync (absoluteUri, role, ofObjectToReturn);
+ }
+#endif
#endregion
}
diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader2.cs b/mcs/class/System.XML/System.Xml/XmlTextReader2.cs
index 3ec73b451f8..2110bb62f17 100644
--- a/mcs/class/System.XML/System.Xml/XmlTextReader2.cs
+++ b/mcs/class/System.XML/System.Xml/XmlTextReader2.cs
@@ -254,9 +254,11 @@ namespace System.Xml
get { return entity != null ? ReadState.Interactive : source.ReadState; }
}
+#if !NET_4_5
public override XmlReaderSettings Settings {
get { return base.Settings; }
}
+#endif
public override string Value {
get { return Current.Value; }
diff --git a/mcs/class/System.XML/System.Xml/XmlUrlResolver.cs b/mcs/class/System.XML/System.Xml/XmlUrlResolver.cs
index 9745f5b6f69..404a4d3f228 100644
--- a/mcs/class/System.XML/System.Xml/XmlUrlResolver.cs
+++ b/mcs/class/System.XML/System.Xml/XmlUrlResolver.cs
@@ -30,6 +30,10 @@
using System.Net;
using System.IO;
using System.Text;
+#if NET_4_5
+using System.Net.Cache;
+using System.Threading.Tasks;
+#endif
namespace System.Xml
{
@@ -37,6 +41,10 @@ namespace System.Xml
{
// Field
ICredentials credential;
+#if NET_4_5
+ RequestCachePolicy cachePolicy;
+ IWebProxy proxy;
+#endif
// Constructor
public XmlUrlResolver ()
@@ -50,6 +58,16 @@ namespace System.Xml
set { credential = value; }
}
+#if NET_4_5
+ public RequestCachePolicy CachePolicy {
+ set { cachePolicy = value; }
+ }
+
+ public IWebProxy Proxy {
+ set { proxy = value; }
+ }
+#endif
+
// Methods
public override object GetEntity (Uri absoluteUri, string role, Type ofObjectToReturn)
{
@@ -71,6 +89,12 @@ namespace System.Xml
// (MS documentation says) parameter role isn't used yet.
WebRequest req = WebRequest.Create (absoluteUri);
+#if NET_4_5
+ if (cachePolicy != null)
+ req.CachePolicy = cachePolicy;
+ if (proxy != null)
+ req.Proxy = proxy;
+#endif
if (credential != null)
req.Credentials = credential;
return req.GetResponse().GetResponseStream();
@@ -93,5 +117,36 @@ namespace System.Xml
.Replace ("%20", " ")
.Replace ("%25", "%");
}
+
+#if NET_4_5
+ public override async Task<object> GetEntityAsync (
+ 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);
+ if (cachePolicy != null)
+ req.CachePolicy = cachePolicy;
+ if (proxy != null)
+ req.Proxy = proxy;
+ if (credential != null)
+ req.Credentials = credential;
+ var res = await req.GetResponseAsync ();
+ return res.GetResponseStream ();
+ }
+#endif
}
}