SvgDtdResolver.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Resources;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Reflection;
  7. using System.Xml;
  8. #pragma warning disable
  9. namespace Svg
  10. {
  11. internal class SvgDtdResolver : XmlUrlResolver
  12. {
  13. /// <summary>
  14. /// Maps a URI to an object containing the actual resource.
  15. /// </summary>
  16. /// <param name="absoluteUri">The URI returned from <see cref="M:System.Xml.XmlResolver.ResolveUri(System.Uri,System.String)"/></param>
  17. /// <param name="role">The current implementation does not use this parameter when resolving URIs. This is provided for future extensibility purposes. For example, this can be mapped to the xlink:role and used as an implementation specific argument in other scenarios.</param>
  18. /// <param name="ofObjectToReturn">The type of object to return. The current implementation only returns System.IO.Stream objects.</param>
  19. /// <returns>
  20. /// A System.IO.Stream object or null if a type other than stream is specified.
  21. /// </returns>
  22. /// <exception cref="T:System.Xml.XmlException">
  23. /// <paramref name="ofObjectToReturn"/> is neither null nor a Stream type. </exception>
  24. /// <exception cref="T:System.UriFormatException">The specified URI is not an absolute URI. </exception>
  25. /// <exception cref="T:System.NullReferenceException">
  26. /// <paramref name="absoluteUri"/> is null. </exception>
  27. /// <exception cref="T:System.Exception">There is a runtime error (for example, an interrupted server connection). </exception>
  28. public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
  29. {
  30. if (absoluteUri.ToString().IndexOf("svg", StringComparison.InvariantCultureIgnoreCase) > -1)
  31. {
  32. string svg11Path;
  33. svg11Path = "FastReport.Resources.SVG.svg11.dtd";
  34. return Assembly.GetExecutingAssembly().GetManifestResourceStream(svg11Path);
  35. }
  36. else
  37. {
  38. return base.GetEntity(absoluteUri, role, ofObjectToReturn);
  39. }
  40. }
  41. }
  42. }
  43. #pragma warning restore