157 lines
5.7 KiB
C#
157 lines
5.7 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace System.Security.Permissions
|
|
{
|
|
/// <summary>Represents access to generic isolated storage capabilities.</summary>
|
|
// Token: 0x02000552 RID: 1362
|
|
[ComVisible(true)]
|
|
[Serializable]
|
|
public abstract class IsolatedStoragePermission : CodeAccessPermission, IUnrestrictedPermission
|
|
{
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.IsolatedStoragePermission" /> class with either restricted or unrestricted permission as specified.</summary>
|
|
/// <param name="state">One of the <see cref="T:System.Security.Permissions.PermissionState" /> values. </param>
|
|
/// <exception cref="T:System.ArgumentException">The <paramref name="state" /> parameter is not a valid value of <see cref="T:System.Security.Permissions.PermissionState" />. </exception>
|
|
// Token: 0x060031BA RID: 12730 RVA: 0x000AB058 File Offset: 0x000A9258
|
|
protected IsolatedStoragePermission(PermissionState state)
|
|
{
|
|
if (CodeAccessPermission.CheckPermissionState(state, true) == PermissionState.Unrestricted)
|
|
{
|
|
this.UsageAllowed = IsolatedStorageContainment.UnrestrictedIsolatedStorage;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the quota on the overall size of each user's total store.</summary>
|
|
/// <returns>The size, in bytes, of the resource allocated to the user.</returns>
|
|
// Token: 0x170009BA RID: 2490
|
|
// (get) Token: 0x060031BB RID: 12731 RVA: 0x000AB078 File Offset: 0x000A9278
|
|
// (set) Token: 0x060031BC RID: 12732 RVA: 0x000AB080 File Offset: 0x000A9280
|
|
public long UserQuota
|
|
{
|
|
get
|
|
{
|
|
return this.m_userQuota;
|
|
}
|
|
set
|
|
{
|
|
this.m_userQuota = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the type of isolated storage containment allowed.</summary>
|
|
/// <returns>One of the <see cref="T:System.Security.Permissions.IsolatedStorageContainment" /> values.</returns>
|
|
// Token: 0x170009BB RID: 2491
|
|
// (get) Token: 0x060031BD RID: 12733 RVA: 0x000AB08C File Offset: 0x000A928C
|
|
// (set) Token: 0x060031BE RID: 12734 RVA: 0x000AB094 File Offset: 0x000A9294
|
|
public IsolatedStorageContainment UsageAllowed
|
|
{
|
|
get
|
|
{
|
|
return this.m_allowed;
|
|
}
|
|
set
|
|
{
|
|
if (!Enum.IsDefined(typeof(IsolatedStorageContainment), value))
|
|
{
|
|
string text = string.Format(Locale.GetText("Invalid enum {0}"), value);
|
|
throw new ArgumentException(text, "IsolatedStorageContainment");
|
|
}
|
|
this.m_allowed = value;
|
|
if (this.m_allowed == IsolatedStorageContainment.UnrestrictedIsolatedStorage)
|
|
{
|
|
this.m_userQuota = long.MaxValue;
|
|
this.m_machineQuota = long.MaxValue;
|
|
this.m_expirationDays = long.MaxValue;
|
|
this.m_permanentData = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Returns a value indicating whether the current permission is unrestricted.</summary>
|
|
/// <returns>true if the current permission is unrestricted; otherwise, false.</returns>
|
|
// Token: 0x060031BF RID: 12735 RVA: 0x000AB128 File Offset: 0x000A9328
|
|
public bool IsUnrestricted()
|
|
{
|
|
return IsolatedStorageContainment.UnrestrictedIsolatedStorage == this.m_allowed;
|
|
}
|
|
|
|
/// <summary>Creates an XML encoding of the permission and its current state.</summary>
|
|
/// <returns>An XML encoding of the permission, including any state information.</returns>
|
|
// Token: 0x060031C0 RID: 12736 RVA: 0x000AB138 File Offset: 0x000A9338
|
|
public override SecurityElement ToXml()
|
|
{
|
|
SecurityElement securityElement = base.Element(1);
|
|
if (this.m_allowed == IsolatedStorageContainment.UnrestrictedIsolatedStorage)
|
|
{
|
|
securityElement.AddAttribute("Unrestricted", "true");
|
|
}
|
|
else
|
|
{
|
|
securityElement.AddAttribute("Allowed", this.m_allowed.ToString());
|
|
if (this.m_userQuota > 0L)
|
|
{
|
|
securityElement.AddAttribute("UserQuota", this.m_userQuota.ToString());
|
|
}
|
|
}
|
|
return securityElement;
|
|
}
|
|
|
|
/// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary>
|
|
/// <param name="esd">The XML encoding to use to reconstruct the permission. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">The <paramref name="esd" /> parameter is null. </exception>
|
|
/// <exception cref="T:System.ArgumentException">The <paramref name="esd" /> parameter is not a valid permission element.-or- The <paramref name="esd" /> parameter's version number is not valid. </exception>
|
|
// Token: 0x060031C1 RID: 12737 RVA: 0x000AB1B4 File Offset: 0x000A93B4
|
|
public override void FromXml(SecurityElement esd)
|
|
{
|
|
CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
|
|
this.m_userQuota = 0L;
|
|
this.m_machineQuota = 0L;
|
|
this.m_expirationDays = 0L;
|
|
this.m_permanentData = false;
|
|
this.m_allowed = IsolatedStorageContainment.None;
|
|
if (CodeAccessPermission.IsUnrestricted(esd))
|
|
{
|
|
this.UsageAllowed = IsolatedStorageContainment.UnrestrictedIsolatedStorage;
|
|
}
|
|
else
|
|
{
|
|
string text = esd.Attribute("Allowed");
|
|
if (text != null)
|
|
{
|
|
this.UsageAllowed = (IsolatedStorageContainment)((int)Enum.Parse(typeof(IsolatedStorageContainment), text));
|
|
}
|
|
text = esd.Attribute("UserQuota");
|
|
if (text != null)
|
|
{
|
|
Exception ex;
|
|
long.Parse(text, true, out this.m_userQuota, out ex);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x060031C2 RID: 12738 RVA: 0x000AB260 File Offset: 0x000A9460
|
|
internal bool IsEmpty()
|
|
{
|
|
return this.m_userQuota == 0L && this.m_allowed == IsolatedStorageContainment.None;
|
|
}
|
|
|
|
// Token: 0x04001469 RID: 5225
|
|
private const int version = 1;
|
|
|
|
// Token: 0x0400146A RID: 5226
|
|
internal long m_userQuota;
|
|
|
|
// Token: 0x0400146B RID: 5227
|
|
internal long m_machineQuota;
|
|
|
|
// Token: 0x0400146C RID: 5228
|
|
internal long m_expirationDays;
|
|
|
|
// Token: 0x0400146D RID: 5229
|
|
internal bool m_permanentData;
|
|
|
|
// Token: 0x0400146E RID: 5230
|
|
internal IsolatedStorageContainment m_allowed;
|
|
}
|
|
}
|