ApplicationDirectoryMembershipCondition.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // System.Security.Policy.ApplicationDirectoryMembershipCondition
  2. //
  3. // Author(s):
  4. // Nick Drochak ([email protected])
  5. // Jackson Harper ([email protected])
  6. //
  7. // (C) 2002 Nick Drochak, All rights reserved.
  8. using System.Security;
  9. namespace System.Security.Policy
  10. {
  11. [Serializable]
  12. public sealed class ApplicationDirectoryMembershipCondition :
  13. IMembershipCondition,
  14. ISecurityEncodable,
  15. ISecurityPolicyEncodable
  16. {
  17. // Tag for Xml Data
  18. private static readonly string XmlTag = "IMembershipCondition";
  19. // Methods
  20. [MonoTODO]
  21. public bool Check(Evidence evidence) {
  22. throw new NotImplementedException ();
  23. }
  24. public IMembershipCondition Copy() {
  25. return new ApplicationDirectoryMembershipCondition ();
  26. }
  27. public override bool Equals(object o) {
  28. return o is ApplicationDirectoryMembershipCondition;
  29. }
  30. public void FromXml(SecurityElement e) {
  31. FromXml (e, null);
  32. }
  33. public void FromXml(SecurityElement e, PolicyLevel level) {
  34. if (null == e)
  35. throw new ArgumentNullException ();
  36. if (XmlTag != e.Tag)
  37. throw new ArgumentException("e","The Tag of SecurityElement must be "
  38. + ApplicationDirectoryMembershipCondition.XmlTag);
  39. }
  40. /// <summary>
  41. /// All instances of ApplicationDirectoryMembershipCondition are equal so they should
  42. /// have the same hashcode
  43. /// </summary>
  44. public override int GetHashCode()
  45. {
  46. return typeof (ApplicationDirectoryMembershipCondition).GetHashCode ();
  47. }
  48. public override string ToString()
  49. {
  50. return "ApplicationDirectory";
  51. }
  52. public SecurityElement ToXml()
  53. {
  54. return ToXml (null);
  55. }
  56. public SecurityElement ToXml(PolicyLevel level)
  57. {
  58. SecurityElement element = new SecurityElement (XmlTag);
  59. Type type = GetType ();
  60. string classString = type.FullName + ", " + type.Assembly;
  61. element.AddAttribute ("class", classString);
  62. element.AddAttribute ("version", "1");
  63. return element;
  64. }
  65. }
  66. }