You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.179
Former-commit-id: a536d4f20e27294d8bbc2184d75f3a22364f7ba1
This commit is contained in:
parent
966bba02bb
commit
fad71374d0
42
external/api-doc-tools/monodoc/Mono.Documentation/ManifestResourceResolver.cs
vendored
Normal file
42
external/api-doc-tools/monodoc/Mono.Documentation/ManifestResourceResolver.cs
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
|
||||
namespace Mono.Documentation {
|
||||
public class ManifestResourceResolver : XmlUrlResolver {
|
||||
private string[] dirs;
|
||||
|
||||
public ManifestResourceResolver (params string[] dirs)
|
||||
{
|
||||
this.dirs = (string[]) dirs.Clone ();
|
||||
}
|
||||
|
||||
public override Uri ResolveUri (Uri baseUri, string relativeUri)
|
||||
{
|
||||
if (Array.IndexOf (
|
||||
Assembly.GetExecutingAssembly ().GetManifestResourceNames (),
|
||||
relativeUri) >= 0)
|
||||
return new Uri ("x-resource:///" + relativeUri);
|
||||
foreach (var dir in dirs) {
|
||||
if (File.Exists (Path.Combine (dir, relativeUri)))
|
||||
return base.ResolveUri (new Uri ("file://" + new DirectoryInfo (dir).FullName + "/"),
|
||||
relativeUri);
|
||||
}
|
||||
return base.ResolveUri (baseUri, relativeUri);
|
||||
}
|
||||
|
||||
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.Scheme != "x-resource")
|
||||
return base.GetEntity (absoluteUri, role, ofObjectToReturn);
|
||||
return Assembly.GetExecutingAssembly().GetManifestResourceStream (
|
||||
absoluteUri.Segments [1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user