SecurityException.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // System.Security.SecurityException.cs
  3. //
  4. // Author:
  5. // Nick Drochak([email protected])
  6. //
  7. // (C) Nick Drochak
  8. //
  9. using System.Runtime.Serialization;
  10. using System.Globalization;
  11. namespace System.Security {
  12. [Serializable]
  13. public class SecurityException : SystemException {
  14. // Fields
  15. string permissionState;
  16. Type permissionType;
  17. // Properties
  18. public string PermissionState
  19. {
  20. get { return permissionState; }
  21. }
  22. public Type PermissionType
  23. {
  24. get { return permissionType; }
  25. }
  26. // Constructors
  27. public SecurityException ()
  28. : base (Locale.GetText ("A security error has been detected."))
  29. {
  30. }
  31. public SecurityException (string message)
  32. : base (message)
  33. {
  34. }
  35. protected SecurityException (SerializationInfo info, StreamingContext context)
  36. : base (info, context)
  37. {
  38. permissionState = info.GetString ("permissionState");
  39. }
  40. public SecurityException (string message, Exception inner)
  41. : base (message, inner)
  42. {
  43. }
  44. public SecurityException (string message, Type type)
  45. : base (message)
  46. {
  47. permissionType = type;
  48. }
  49. public SecurityException (string message, Type type, string state)
  50. : base (message)
  51. {
  52. permissionType = type;
  53. permissionState = state;
  54. }
  55. // Methods
  56. public override void GetObjectData (SerializationInfo info, StreamingContext context)
  57. {
  58. base.GetObjectData (info, context);
  59. info.AddValue ("PermissionState", permissionState);
  60. }
  61. public override string ToString ()
  62. {
  63. return permissionType.FullName + ": " + permissionState;
  64. }
  65. }
  66. }