SecurityException.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. public class SecurityException : Exception {
  13. // Fields
  14. string permissionState;
  15. Type permissionType;
  16. // Properties
  17. public string PermissionState
  18. {
  19. get { return permissionState; }
  20. }
  21. public Type PermissionType
  22. {
  23. get { return permissionType; }
  24. }
  25. // Constructors
  26. public SecurityException ()
  27. : base (Locale.GetText ("A security error has been detected."))
  28. {
  29. }
  30. public SecurityException (string message)
  31. : base (message)
  32. {
  33. }
  34. protected SecurityException (SerializationInfo info, StreamingContext context)
  35. : base (info, context)
  36. {
  37. permissionState = info.GetString ("permissionState");
  38. }
  39. public SecurityException (string message, Exception inner)
  40. : base (message, inner)
  41. {
  42. }
  43. public SecurityException (string message, Type type)
  44. : base (message)
  45. {
  46. permissionType = type;
  47. }
  48. public SecurityException (string message, Type type, string state)
  49. : base (message)
  50. {
  51. permissionType = type;
  52. permissionState = state;
  53. }
  54. // Methods
  55. public override void GetObjectData (SerializationInfo info, StreamingContext context)
  56. {
  57. base.GetObjectData (info, context);
  58. info.AddValue ("PermissionState", permissionState);
  59. }
  60. public override string ToString ()
  61. {
  62. return permissionType.FullName + ": " + permissionState;
  63. }
  64. }
  65. }