Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@ -30,10 +30,8 @@
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
{
@ -41,10 +39,8 @@ namespace System.Xml
{
// Field
ICredentials credential;
#if NET_4_5
RequestCachePolicy cachePolicy;
IWebProxy proxy;
#endif
// Constructor
public XmlUrlResolver ()
@ -58,7 +54,6 @@ namespace System.Xml
set { credential = value; }
}
#if NET_4_5
public RequestCachePolicy CachePolicy {
set { cachePolicy = value; }
}
@ -66,7 +61,6 @@ namespace System.Xml
public IWebProxy Proxy {
set { proxy = value; }
}
#endif
// Methods
public override object GetEntity (Uri absoluteUri, string role, Type ofObjectToReturn)
@ -76,10 +70,8 @@ namespace System.Xml
if (ofObjectToReturn != typeof (Stream))
throw new XmlException ("This object type is not supported.");
#if NET_2_0
if (!absoluteUri.IsAbsoluteUri)
throw new ArgumentException ("uri must be absolute.", "absoluteUri");
#endif
if (absoluteUri.Scheme == "file") {
if (absoluteUri.AbsolutePath == String.Empty)
@ -89,7 +81,6 @@ namespace System.Xml
// (MS documentation says) parameter role isn't used yet.
WebRequest req = WebRequest.Create (absoluteUri);
#if NET_4_5
#if !NET_2_1
if (cachePolicy != null)
@ -97,18 +88,15 @@ namespace System.Xml
#endif
if (proxy != null)
req.Proxy = proxy;
#endif
if (credential != null)
req.Credentials = credential;
return req.GetResponse().GetResponseStream();
}
#if NET_2_0
public override Uri ResolveUri (Uri baseUri, string relativeUri)
{
return base.ResolveUri (baseUri, relativeUri);
}
#endif
// see also XmlResolver.EscapeRelativeUriBody().
private string UnescapeRelativeUriBody (string src)
@ -121,7 +109,6 @@ namespace System.Xml
.Replace ("%25", "%");
}
#if NET_4_5
public override async Task<object> GetEntityAsync (
Uri absoluteUri, string role, Type ofObjectToReturn)
{
@ -149,9 +136,12 @@ namespace System.Xml
req.Proxy = proxy;
if (credential != null)
req.Credentials = credential;
#if BOOTSTRAP_BASIC
return null;
#else
var res = await req.GetResponseAsync ().ConfigureAwait (false);
return res.GetResponseStream ();
}
#endif
}
}
}