コード例 #1
0
        /// <summary>Creates and returns a permission that is the intersection of the current permission and the specified permission.</summary>
        /// <returns>A new permission that represents the intersection of the current permission and the specified permission. This new permission is null if the intersection is empty.</returns>
        /// <param name="target">A permission to intersect with the current permission object. It must be of the same type as the current permission. </param>
        /// <exception cref="T:System.ArgumentException">The <paramref name="target" /> parameter is not null and is not of the same type as the current permission. </exception>
        public override IPermission Intersect(IPermission target)
        {
            IsolatedStorageFilePermission isolatedStorageFilePermission = this.Cast(target);

            if (isolatedStorageFilePermission == null)
            {
                return(null);
            }
            if (base.IsEmpty() && isolatedStorageFilePermission.IsEmpty())
            {
                return(null);
            }
            return(new IsolatedStorageFilePermission(PermissionState.None)
            {
                m_userQuota = ((this.m_userQuota >= isolatedStorageFilePermission.m_userQuota) ? isolatedStorageFilePermission.m_userQuota : this.m_userQuota),
                m_machineQuota = ((this.m_machineQuota >= isolatedStorageFilePermission.m_machineQuota) ? isolatedStorageFilePermission.m_machineQuota : this.m_machineQuota),
                m_expirationDays = ((this.m_expirationDays >= isolatedStorageFilePermission.m_expirationDays) ? isolatedStorageFilePermission.m_expirationDays : this.m_expirationDays),
                m_permanentData = (this.m_permanentData && isolatedStorageFilePermission.m_permanentData),
                UsageAllowed = ((this.m_allowed >= isolatedStorageFilePermission.m_allowed) ? isolatedStorageFilePermission.m_allowed : this.m_allowed)
            });
        }
コード例 #2
0
        public override IPermission Intersect(IPermission target)
        {
            IsolatedStorageFilePermission isfp = Cast(target);

            if (isfp == null)
            {
                return(null);
            }
            if (IsEmpty() && isfp.IsEmpty())
            {
                return(null);
            }

            IsolatedStorageFilePermission p = new IsolatedStorageFilePermission(PermissionState.None);

            p.m_userQuota      = (m_userQuota < isfp.m_userQuota) ? m_userQuota : isfp.m_userQuota;
            p.m_machineQuota   = (m_machineQuota < isfp.m_machineQuota) ? m_machineQuota : isfp.m_machineQuota;
            p.m_expirationDays = (m_expirationDays < isfp.m_expirationDays) ? m_expirationDays : isfp.m_expirationDays;
            p.m_permanentData  = (m_permanentData && isfp.m_permanentData);
            // UsageAllowed == Unrestricted is a special case handled by the property
            p.UsageAllowed = (m_allowed < isfp.m_allowed) ? m_allowed : isfp.m_allowed;
            return(p);
        }