﻿// Decompiled with JetBrains decompiler
// Type: System.IO.IsolatedStorage.IsolatedStorageSecurityState
// Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 255ABCDF-D9D6-4E3D-BAD4-F74D4CE3D7A8
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll

using System;
using System.Runtime;
using System.Security;

namespace System.IO.IsolatedStorage
{
  /// <summary>
  /// Provides settings for maintaining the quota size for isolated storage.
  /// </summary>
  [SecurityCritical]
  public class IsolatedStorageSecurityState : SecurityState
  {
    private long m_UsedSize;
    private long m_Quota;
    private IsolatedStorageSecurityOptions m_Options;

    /// <summary>
    /// Gets the option for managing isolated storage security.
    /// </summary>
    /// 
    /// <returns>
    /// The option to increase the isolated quota storage size.
    /// </returns>
    public IsolatedStorageSecurityOptions Options
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this.m_Options;
      }
    }

    /// <summary>
    /// Gets the current usage size in isolated storage.
    /// </summary>
    /// 
    /// <returns>
    /// The current usage size, in bytes.
    /// </returns>
    public long UsedSize
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this.m_UsedSize;
      }
    }

    /// <summary>
    /// Gets or sets the current size of the quota for isolated storage.
    /// </summary>
    /// 
    /// <returns>
    /// The current quota size, in bytes.
    /// </returns>
    public long Quota
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this.m_Quota;
      }
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] set
      {
        this.m_Quota = value;
      }
    }

    [SecurityCritical]
    private IsolatedStorageSecurityState()
    {
    }

    internal static IsolatedStorageSecurityState CreateStateToIncreaseQuotaForApplication(long newQuota, long usedSize)
    {
      return new IsolatedStorageSecurityState()
      {
        m_Options = IsolatedStorageSecurityOptions.IncreaseQuotaForApplication,
        m_Quota = newQuota,
        m_UsedSize = usedSize
      };
    }

    /// <exception cref="T:System.IO.IsolatedStorage.IsolatedStorageException">The state is not available.</exception>
    [SecurityCritical]
    public override void EnsureState()
    {
      if (!this.IsStateAvailable())
        throw new IsolatedStorageException(Environment.GetResourceString("IsolatedStorage_Operation"));
    }
  }
}
