ApplicationDirectory.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // System.Security.Policy.ApplicationDirectory
  2. //
  3. // Author:
  4. // Jackson Harper ([email protected])
  5. //
  6. // (C) 2002 Jackson Harper, All rights reserved.
  7. using System;
  8. namespace System.Security.Policy {
  9. [MonoTODO("This class should use a URLString like class instead of just a string")]
  10. public sealed class ApplicationDirectory {
  11. private string directory;
  12. //
  13. // Public Constructors
  14. //
  15. public ApplicationDirectory(string name)
  16. {
  17. if (null == name)
  18. throw new ArgumentNullException ();
  19. directory = name;
  20. }
  21. //
  22. // Public Properties
  23. //
  24. public string Directory {
  25. get { return directory; }
  26. }
  27. //
  28. // Public Methods
  29. //
  30. public object Copy()
  31. {
  32. return new ApplicationDirectory (Directory);
  33. }
  34. [MonoTODO("This needs to check for security subsets")]
  35. public override bool Equals(object other)
  36. {
  37. if (null != other && (other is ApplicationDirectory)) {
  38. ApplicationDirectory compare = (ApplicationDirectory)other;
  39. return compare.directory.Equals(directory);
  40. }
  41. return false;
  42. }
  43. /// <summary>
  44. /// This does not return the exact same results as the MS version
  45. /// </summary>
  46. public override int GetHashCode()
  47. {
  48. return directory.GetHashCode ();
  49. }
  50. public override string ToString()
  51. {
  52. return ToXml ().ToString ();
  53. }
  54. private SecurityElement ToXml()
  55. {
  56. SecurityElement element = new SecurityElement (GetType().FullName);
  57. element.AddAttribute ("version", "1");
  58. element.AddAttribute ("Directory", Directory);
  59. return element;
  60. }
  61. }
  62. }