(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Mono.Xml.Ext / Mono.Xml / XmlStoredResolver.cs
blob8464e32d5f312624385f2562ddab1b0906cbb92b
1 //
2 // XmlStoredResolver.cs
3 //
4 // Author: Atsushi Enomoto <atsushi@ximian.com>
5 //
6 // This code is too short to have "creativity". (thus, there must be no
7 // copyright on this code). Feel free to use anywhere.
8 //
9 // Use like this:
11 // XmlDocument doc = new XmlDocument ();
12 // XmlStoredResolver r = new XmlStoredResolver (new XmlUrlResolver ());
13 // r.Add ("http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd",
14 // "svg10.dtd");
15 // doc.XmlResolver = r;
17 using System;
18 using System.Collections;
19 using System.Net;
20 using System.Xml;
22 namespace Mono.Xml
24 public class XmlStoredResolver : XmlResolver
26 XmlResolver external;
27 XmlResolver local;
28 IDictionary uriTable;
30 public XmlStoredResolver (XmlResolver resolver)
31 : this (resolver, resolver, new Hashtable ())
35 public XmlStoredResolver (XmlResolver resolver, IDictionary uriTable)
36 : this (resolver, resolver, uriTable)
40 public XmlStoredResolver (XmlResolver external, XmlResolver local)
41 : this (external, local, new Hashtable ())
45 public XmlStoredResolver (XmlResolver external, XmlResolver local, IDictionary uriTable)
47 this.external = external;
48 this.local = local;
49 this.uriTable = uriTable;
52 public override ICredentials Credentials {
53 set {
54 external.Credentials = value;
55 if (local != external)
56 local.Credentials = value;
60 public IDictionary Mapping {
61 get { return uriTable; }
64 public void Add (string nominalUri, string actualLocation)
66 uriTable.Add (
67 external.ResolveUri (null, nominalUri).ToString (),
68 local.ResolveUri (null, actualLocation).ToString ());
71 public override object GetEntity (Uri uri, string role, Type returnType)
73 string uriString = uri.ToString ();
74 string actualLocation = (string) uriTable [uriString];
75 if (actualLocation == null)
76 return external.GetEntity (uri, role, returnType);
77 else
78 return local.GetEntity (local.ResolveUri (null, actualLocation), role, returnType);