You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@ -0,0 +1,48 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="XmlPreloadedResolver.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// <owner current="true" primary="true">[....]</owner>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.Xml.Resolvers {
|
||||
|
||||
//
|
||||
// XmlPreloadedResolver is an XmlResolver that which can be pre-loaded with data.
|
||||
// By default it contains well-known DTDs for XHTML 1.0 and RSS 0.91.
|
||||
// Custom mappings of URIs to data can be added with the Add method.
|
||||
//
|
||||
public partial class XmlPreloadedResolver : XmlResolver {
|
||||
|
||||
public override Task<Object> GetEntityAsync(Uri absoluteUri,
|
||||
string role,
|
||||
Type ofObjectToReturn) {
|
||||
|
||||
if (absoluteUri == null) {
|
||||
throw new ArgumentNullException("absoluteUri");
|
||||
}
|
||||
|
||||
PreloadedData data;
|
||||
if (!mappings.TryGetValue(absoluteUri, out data)) {
|
||||
if (fallbackResolver != null) {
|
||||
return fallbackResolver.GetEntityAsync(absoluteUri, role, ofObjectToReturn);
|
||||
}
|
||||
throw new XmlException(Res.GetString(Res.Xml_CannotResolveUrl, absoluteUri.ToString()));
|
||||
}
|
||||
|
||||
if (ofObjectToReturn == null || ofObjectToReturn == typeof(Stream) || ofObjectToReturn == typeof(Object)) {
|
||||
return Task.FromResult<Object>(data.AsStream());
|
||||
}
|
||||
else if (ofObjectToReturn == typeof(TextReader)) {
|
||||
return Task.FromResult<Object>(data.AsTextReader());
|
||||
}
|
||||
else {
|
||||
throw new XmlException(Res.GetString(Res.Xml_UnsupportedClass));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user