public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } if (!VerifyType(target)) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)); } KeyContainerPermission operand = (KeyContainerPermission)target; if (this.IsEmpty() || operand.IsEmpty()) { return(null); } KeyContainerPermissionFlags flags_intersect = operand.m_flags & this.m_flags; KeyContainerPermission cp = new KeyContainerPermission(flags_intersect); foreach (KeyContainerPermissionAccessEntry accessEntry in AccessEntries) { cp.AddAccessEntryAndIntersect(accessEntry, operand); } foreach (KeyContainerPermissionAccessEntry accessEntry in operand.AccessEntries) { cp.AddAccessEntryAndIntersect(accessEntry, this); } return(cp.IsEmpty() ? null : cp); }
/// <summary>创建并返回一个权限,该权限是当前权限和指定权限的交集。</summary> /// <returns>一个新权限,它表示当前权限与指定权限的交集。如果交集为空,则此新权限为 null。</returns> /// <param name="target">要与当前权限相交的权限。它必须与当前权限属于同一类型。</param> /// <exception cref="T:System.ArgumentException"> /// <paramref name="target" /> 不是 null,并且未指定与当前权限属于同一类型的权限。</exception> public override IPermission Intersect(IPermission target) { if (target == null) { return((IPermission)null); } if (!this.VerifyType(target)) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", (object)this.GetType().FullName)); } KeyContainerPermission target1 = (KeyContainerPermission)target; if (this.IsEmpty() || target1.IsEmpty()) { return((IPermission)null); } KeyContainerPermission containerPermission = new KeyContainerPermission(target1.m_flags & this.m_flags); foreach (KeyContainerPermissionAccessEntry accessEntry in this.AccessEntries) { containerPermission.AddAccessEntryAndIntersect(accessEntry, target1); } foreach (KeyContainerPermissionAccessEntry accessEntry in target1.AccessEntries) { containerPermission.AddAccessEntryAndIntersect(accessEntry, this); } if (!containerPermission.IsEmpty()) { return((IPermission)containerPermission); } return((IPermission)null); }
public override IPermission Intersect(IPermission target) { if (target != null) { if (!base.VerifyType(target)) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } KeyContainerPermission permission = (KeyContainerPermission)target; if (this.IsEmpty() || permission.IsEmpty()) { return(null); } KeyContainerPermissionFlags flags = permission.m_flags & this.m_flags; KeyContainerPermission permission2 = new KeyContainerPermission(flags); KeyContainerPermissionAccessEntryEnumerator enumerator = this.AccessEntries.GetEnumerator(); while (enumerator.MoveNext()) { KeyContainerPermissionAccessEntry current = enumerator.Current; permission2.AddAccessEntryAndIntersect(current, permission); } KeyContainerPermissionAccessEntryEnumerator enumerator2 = permission.AccessEntries.GetEnumerator(); while (enumerator2.MoveNext()) { KeyContainerPermissionAccessEntry accessEntry = enumerator2.Current; permission2.AddAccessEntryAndIntersect(accessEntry, this); } if (!permission2.IsEmpty()) { return(permission2); } } return(null); }
/// <summary>Creates and returns a permission that is the intersection of the current permission and the specified permission.</summary> /// <param name="target">A permission to intersect with the current permission. It must be the same type as the current permission. </param> /// <returns>A new permission that represents the intersection of the current permission and the specified permission. This new permission is <see langword="null" /> if the intersection is empty.</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: 0x060026C6 RID: 9926 RVA: 0x0008C61C File Offset: 0x0008A81C public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } if (!base.VerifyType(target)) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } KeyContainerPermission keyContainerPermission = (KeyContainerPermission)target; if (this.IsEmpty() || keyContainerPermission.IsEmpty()) { return(null); } KeyContainerPermissionFlags flags = keyContainerPermission.m_flags & this.m_flags; KeyContainerPermission keyContainerPermission2 = new KeyContainerPermission(flags); foreach (KeyContainerPermissionAccessEntry accessEntry in this.AccessEntries) { keyContainerPermission2.AddAccessEntryAndIntersect(accessEntry, keyContainerPermission); } foreach (KeyContainerPermissionAccessEntry accessEntry2 in keyContainerPermission.AccessEntries) { keyContainerPermission2.AddAccessEntryAndIntersect(accessEntry2, this); } if (!keyContainerPermission2.IsEmpty()) { return(keyContainerPermission2); } return(null); }
public override IPermission Intersect (IPermission target) { if (target == null) return null; if (!VerifyType(target)) throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)); KeyContainerPermission operand = (KeyContainerPermission) target; if (this.IsEmpty() || operand.IsEmpty()) return null; KeyContainerPermissionFlags flags_intersect = operand.m_flags & this.m_flags; KeyContainerPermission cp = new KeyContainerPermission(flags_intersect); foreach (KeyContainerPermissionAccessEntry accessEntry in AccessEntries) { cp.AddAccessEntryAndIntersect(accessEntry, operand); } foreach (KeyContainerPermissionAccessEntry accessEntry in operand.AccessEntries) { cp.AddAccessEntryAndIntersect(accessEntry, this); } return cp.IsEmpty() ? null : cp; }
public override IPermission Intersect(IPermission target) { if (target != null) { if (!base.VerifyType(target)) { throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName })); } KeyContainerPermission permission = (KeyContainerPermission) target; if (this.IsEmpty() || permission.IsEmpty()) { return null; } KeyContainerPermissionFlags flags = permission.m_flags & this.m_flags; KeyContainerPermission permission2 = new KeyContainerPermission(flags); KeyContainerPermissionAccessEntryEnumerator enumerator = this.AccessEntries.GetEnumerator(); while (enumerator.MoveNext()) { KeyContainerPermissionAccessEntry current = enumerator.Current; permission2.AddAccessEntryAndIntersect(current, permission); } KeyContainerPermissionAccessEntryEnumerator enumerator2 = permission.AccessEntries.GetEnumerator(); while (enumerator2.MoveNext()) { KeyContainerPermissionAccessEntry accessEntry = enumerator2.Current; permission2.AddAccessEntryAndIntersect(accessEntry, this); } if (!permission2.IsEmpty()) { return permission2; } } return null; }