IsolatedStoragePermission.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // System.Security.Permissions.IsolatedStoragePermission.cs
  3. //
  4. // Piers Haken <[email protected]>
  5. //
  6. // (C) 2002 Ximian, Inc. http://www.ximian.com
  7. //
  8. using System;
  9. using System.Security.Permissions;
  10. namespace System.Security.Permissions
  11. {
  12. [Serializable]
  13. public abstract class IsolatedStoragePermission : CodeAccessPermission, IUnrestrictedPermission
  14. {
  15. internal long m_userQuota;
  16. internal long m_machineQuota;
  17. internal long m_expirationDays;
  18. internal bool m_permanentData;
  19. internal IsolatedStorageContainment m_allowed;
  20. public IsolatedStoragePermission (PermissionState state)
  21. {
  22. if (state == PermissionState.None)
  23. {
  24. m_userQuota = 0;
  25. m_machineQuota = 0;
  26. m_expirationDays = 0;
  27. m_permanentData = false;
  28. m_allowed = IsolatedStorageContainment.None;
  29. }
  30. else if (state == PermissionState.Unrestricted)
  31. {
  32. m_userQuota = Int64.MaxValue;
  33. m_machineQuota = Int64.MaxValue;
  34. m_expirationDays = Int64.MaxValue ;
  35. m_permanentData = true;
  36. m_allowed = IsolatedStorageContainment.UnrestrictedIsolatedStorage;
  37. }
  38. else
  39. {
  40. throw new ArgumentException("Invalid Permission state");
  41. }
  42. }
  43. public long UserQuota
  44. {
  45. set { m_userQuota = value; }
  46. get { return m_userQuota; }
  47. }
  48. public IsolatedStorageContainment UsageAllowed
  49. {
  50. set { m_allowed = value; }
  51. get { return m_allowed; }
  52. }
  53. public bool IsUnrestricted ()
  54. {
  55. return IsolatedStorageContainment.UnrestrictedIsolatedStorage == m_allowed;
  56. }
  57. [MonoTODO]
  58. public override SecurityElement ToXml ()
  59. {
  60. throw new NotImplementedException ();
  61. }
  62. [MonoTODO]
  63. public override void FromXml (SecurityElement esd)
  64. {
  65. throw new NotImplementedException ();
  66. }
  67. }
  68. }