public override IPermission Union(IPermission target)
        {
            if (target == null)
            {
                return(this.Copy());
            }

            if (!VerifyType(target))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName));
            }

            KeyContainerPermission operand = (KeyContainerPermission)target;

            if (this.IsUnrestricted() || operand.IsUnrestricted())
            {
                return(new KeyContainerPermission(PermissionState.Unrestricted));
            }

            KeyContainerPermissionFlags flags_union = (KeyContainerPermissionFlags)(m_flags | operand.m_flags);
            KeyContainerPermission      cp          = new KeyContainerPermission(flags_union);

            foreach (KeyContainerPermissionAccessEntry accessEntry in AccessEntries)
            {
                cp.AddAccessEntryAndUnion(accessEntry, operand);
            }
            foreach (KeyContainerPermissionAccessEntry accessEntry in operand.AccessEntries)
            {
                cp.AddAccessEntryAndUnion(accessEntry, this);
            }
            return(cp.IsEmpty() ? null : cp);
        }
Ejemplo n.º 2
0
        /// <summary>创建一个权限,该权限是当前权限与指定权限的并集。</summary>
        /// <returns>一个新权限,它表示当前权限与指定权限的并集。</returns>
        /// <param name="target">将与当前权限合并的权限。它必须与当前权限属于同一类型。</param>
        /// <exception cref="T:System.ArgumentException">
        /// <paramref name="target" /> 不是 null,并且未指定与当前权限属于同一类型的权限。</exception>
        public override IPermission Union(IPermission target)
        {
            if (target == null)
            {
                return(this.Copy());
            }
            if (!this.VerifyType(target))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", (object)this.GetType().FullName));
            }
            KeyContainerPermission target1 = (KeyContainerPermission)target;

            if (this.IsUnrestricted() || target1.IsUnrestricted())
            {
                return((IPermission) new KeyContainerPermission(PermissionState.Unrestricted));
            }
            KeyContainerPermission containerPermission = new KeyContainerPermission(this.m_flags | target1.m_flags);

            foreach (KeyContainerPermissionAccessEntry accessEntry in this.AccessEntries)
            {
                containerPermission.AddAccessEntryAndUnion(accessEntry, target1);
            }
            foreach (KeyContainerPermissionAccessEntry accessEntry in target1.AccessEntries)
            {
                containerPermission.AddAccessEntryAndUnion(accessEntry, this);
            }
            if (!containerPermission.IsEmpty())
            {
                return((IPermission)containerPermission);
            }
            return((IPermission)null);
        }
Ejemplo n.º 3
0
        public override IPermission Union(IPermission target)
        {
            if (target == null)
            {
                return(this.Copy());
            }
            if (!base.VerifyType(target))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName }));
            }
            KeyContainerPermission permission = (KeyContainerPermission)target;

            if (this.IsUnrestricted() || permission.IsUnrestricted())
            {
                return(new KeyContainerPermission(PermissionState.Unrestricted));
            }
            KeyContainerPermissionFlags flags       = this.m_flags | permission.m_flags;
            KeyContainerPermission      permission2 = new KeyContainerPermission(flags);
            KeyContainerPermissionAccessEntryEnumerator enumerator = this.AccessEntries.GetEnumerator();

            while (enumerator.MoveNext())
            {
                KeyContainerPermissionAccessEntry current = enumerator.Current;
                permission2.AddAccessEntryAndUnion(current, permission);
            }
            KeyContainerPermissionAccessEntryEnumerator enumerator2 = permission.AccessEntries.GetEnumerator();

            while (enumerator2.MoveNext())
            {
                KeyContainerPermissionAccessEntry accessEntry = enumerator2.Current;
                permission2.AddAccessEntryAndUnion(accessEntry, this);
            }
            if (!permission2.IsEmpty())
            {
                return(permission2);
            }
            return(null);
        }
        /// <summary>Creates a permission that is the union of the current permission and the specified permission.</summary>
        /// <param name="target">A permission to combine with the current permission. It must be of the same type as the current permission. </param>
        /// <returns>A new permission that represents the union of the current permission and the specified permission.</returns>
        /// <exception cref="T:System.ArgumentException">
        ///         <paramref name="target" /> is not <see langword="null" /> and does not specify a permission of the same type as the current permission. </exception>
        // Token: 0x060026C7 RID: 9927 RVA: 0x0008C6E8 File Offset: 0x0008A8E8
        public override IPermission Union(IPermission target)
        {
            if (target == null)
            {
                return(this.Copy());
            }
            if (!base.VerifyType(target))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[]
                {
                    base.GetType().FullName
                }));
            }
            KeyContainerPermission keyContainerPermission = (KeyContainerPermission)target;

            if (this.IsUnrestricted() || keyContainerPermission.IsUnrestricted())
            {
                return(new KeyContainerPermission(PermissionState.Unrestricted));
            }
            KeyContainerPermissionFlags flags = this.m_flags | keyContainerPermission.m_flags;
            KeyContainerPermission      keyContainerPermission2 = new KeyContainerPermission(flags);

            foreach (KeyContainerPermissionAccessEntry accessEntry in this.AccessEntries)
            {
                keyContainerPermission2.AddAccessEntryAndUnion(accessEntry, keyContainerPermission);
            }
            foreach (KeyContainerPermissionAccessEntry accessEntry2 in keyContainerPermission.AccessEntries)
            {
                keyContainerPermission2.AddAccessEntryAndUnion(accessEntry2, this);
            }
            if (!keyContainerPermission2.IsEmpty())
            {
                return(keyContainerPermission2);
            }
            return(null);
        }
Ejemplo n.º 5
0
        public override IPermission Union (IPermission target) {
            if (target == null)
                return this.Copy();

            if (!VerifyType(target))
                throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName));            

            KeyContainerPermission operand = (KeyContainerPermission) target;    
            if (this.IsUnrestricted() || operand.IsUnrestricted())
                return new KeyContainerPermission(PermissionState.Unrestricted);

            KeyContainerPermissionFlags flags_union = (KeyContainerPermissionFlags) (m_flags | operand.m_flags);
            KeyContainerPermission cp = new KeyContainerPermission(flags_union);
            foreach (KeyContainerPermissionAccessEntry accessEntry in AccessEntries) {
                cp.AddAccessEntryAndUnion(accessEntry, operand);
            }
            foreach (KeyContainerPermissionAccessEntry accessEntry in operand.AccessEntries) {
                cp.AddAccessEntryAndUnion(accessEntry, this);
            }
            return cp.IsEmpty() ? null : cp;
        }
 public override IPermission Union(IPermission target)
 {
     if (target == null)
     {
         return this.Copy();
     }
     if (!base.VerifyType(target))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName }));
     }
     KeyContainerPermission permission = (KeyContainerPermission) target;
     if (this.IsUnrestricted() || permission.IsUnrestricted())
     {
         return new KeyContainerPermission(PermissionState.Unrestricted);
     }
     KeyContainerPermissionFlags flags = this.m_flags | permission.m_flags;
     KeyContainerPermission permission2 = new KeyContainerPermission(flags);
     KeyContainerPermissionAccessEntryEnumerator enumerator = this.AccessEntries.GetEnumerator();
     while (enumerator.MoveNext())
     {
         KeyContainerPermissionAccessEntry current = enumerator.Current;
         permission2.AddAccessEntryAndUnion(current, permission);
     }
     KeyContainerPermissionAccessEntryEnumerator enumerator2 = permission.AccessEntries.GetEnumerator();
     while (enumerator2.MoveNext())
     {
         KeyContainerPermissionAccessEntry accessEntry = enumerator2.Current;
         permission2.AddAccessEntryAndUnion(accessEntry, this);
     }
     if (!permission2.IsEmpty())
     {
         return permission2;
     }
     return null;
 }