Copy() public method

public Copy ( ) : IPermission
return IPermission
コード例 #1
0
        public override IPermission Intersect(IPermission target)
        {
            FileIOPermission fiop = Cast(target);

            if (fiop == null)
            {
                return(null);
            }

            if (IsUnrestricted())
            {
                return(fiop.Copy());
            }
            if (fiop.IsUnrestricted())
            {
                return(Copy());
            }

            FileIOPermission result = new FileIOPermission(PermissionState.None);

            result.AllFiles      = m_AllFilesAccess & fiop.AllFiles;
            result.AllLocalFiles = m_AllLocalFilesAccess & fiop.AllLocalFiles;

            IntersectKeys(readList, fiop.readList, result.readList);
            IntersectKeys(writeList, fiop.writeList, result.writeList);
            IntersectKeys(appendList, fiop.appendList, result.appendList);
            IntersectKeys(pathList, fiop.pathList, result.pathList);

            return(result.IsEmpty() ? null : result);
        }
コード例 #2
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. It must be 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)
        {
            FileIOPermission fileIOPermission = FileIOPermission.Cast(target);

            if (fileIOPermission == null)
            {
                return(null);
            }
            if (this.IsUnrestricted())
            {
                return(fileIOPermission.Copy());
            }
            if (fileIOPermission.IsUnrestricted())
            {
                return(this.Copy());
            }
            FileIOPermission fileIOPermission2 = new FileIOPermission(PermissionState.None);

            fileIOPermission2.AllFiles      = (this.m_AllFilesAccess & fileIOPermission.AllFiles);
            fileIOPermission2.AllLocalFiles = (this.m_AllLocalFilesAccess & fileIOPermission.AllLocalFiles);
            FileIOPermission.IntersectKeys(this.readList, fileIOPermission.readList, fileIOPermission2.readList);
            FileIOPermission.IntersectKeys(this.writeList, fileIOPermission.writeList, fileIOPermission2.writeList);
            FileIOPermission.IntersectKeys(this.appendList, fileIOPermission.appendList, fileIOPermission2.appendList);
            FileIOPermission.IntersectKeys(this.pathList, fileIOPermission.pathList, fileIOPermission2.pathList);
            return((!fileIOPermission2.IsEmpty()) ? fileIOPermission2 : null);
        }