The Labs \ Source Viewer \ SSCLI \ System.Xml \ XmlResolver

  1. //------------------------------------------------------------------------------
  2. // <copyright file="XmlResolver.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Xml
  16. {
  17.     using System;
  18.     using System.IO;
  19.     using System.Net;
  20.     using System.Text;
  21.     using System.Security;
  22.     using System.Security.Policy;
  23.     using System.Security.Permissions;
  24.    
  25.     /// <include file='doc\XmlResolver.uex' path='docs/doc[@for="XmlResolver"]/*' />
  26.     /// <devdoc>
  27.     /// <para>Resolves external XML resources named by a Uniform
  28.     /// Resource Identifier (URI). This class is <see langword='abstract'/>
  29.     /// .</para>
  30.     /// </devdoc>
  31.     public abstract class XmlResolver
  32.     {
  33.         /// <include file='doc\XmlResolver.uex' path='docs/doc[@for="XmlResolver.GetEntity1"]/*' />
  34.         /// <devdoc>
  35.         /// <para>Maps a
  36.         /// URI to an Object containing the actual resource.</para>
  37.         /// </devdoc>
  38.        
  39.         public abstract object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn);
  40.        
  41.         /// <include file='doc\XmlResolver.uex' path='docs/doc[@for="XmlResolver.ResolveUri"]/*' />
  42.         /// <devdoc>
  43.         /// <para>[To be supplied.]</para>
  44.         /// </devdoc>
  45.         public virtual Uri ResolveUri(Uri baseUri, string relativeUri)
  46.         {
  47.             if (baseUri == null || (!baseUri.IsAbsoluteUri && baseUri.OriginalString.Length == 0)) {
  48.                 Uri uri = new Uri(relativeUri, UriKind.RelativeOrAbsolute);
  49.                 if (!uri.IsAbsoluteUri && uri.OriginalString.Length > 0) {
  50.                     uri = new Uri(Path.GetFullPath(relativeUri));
  51.                 }
  52.                 return uri;
  53.             }
  54.             else {
  55.                 if (relativeUri == null || relativeUri.Length == 0) {
  56.                     return baseUri;
  57.                 }
  58.                 return new Uri(baseUri, relativeUri);
  59.             }
  60.         }
  61.        
  62.         //UE attension
  63.         /// <include file='doc\XmlResolver.uex' path='docs/doc[@for="XmlResolver.Credentials"]/*' />
  64.         /// <devdoc>
  65.         /// <para>[To be supplied.]</para>
  66.         /// </devdoc>
  67.         public abstract ICredentials Credentials {
  68.             set;
  69.         }
  70.     }
  71. }

Developer Fusion