public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } if (target.GetType() != base.GetType()) { throw new ArgumentException(SR.GetString("PermissionTypeMismatch"), "target"); } ResourcePermissionBase base2 = (ResourcePermissionBase)target; if (this.IsUnrestricted()) { return(base2.Copy()); } if (base2.IsUnrestricted()) { return(this.Copy()); } ResourcePermissionBase base3 = null; Hashtable hashtable = (Hashtable)this.IntersectContents(this.rootTable, base2.rootTable); if (hashtable != null) { base3 = this.CreateInstance(); base3.rootTable = hashtable; } return(base3); }
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } if (target.GetType() != this.GetType()) { throw new ArgumentException(SR.GetString(SR.PermissionTypeMismatch), "target"); } ResourcePermissionBase targetPermission = (ResourcePermissionBase)target; if (this.IsUnrestricted()) { return(targetPermission.Copy()); } if (targetPermission.IsUnrestricted()) { return(this.Copy()); } ResourcePermissionBase newPermission = null; Hashtable newPermissionRootTable = (Hashtable)IntersectContents(this.rootTable, targetPermission.rootTable); if (newPermissionRootTable != null) { newPermission = CreateInstance(); newPermission.rootTable = newPermissionRootTable; } return(newPermission); }
public override IPermission Union(IPermission target) { ResourcePermissionBase rpb = Cast(target); if (rpb == null) { return(Copy()); } if (IsEmpty() && rpb.IsEmpty()) { return(null); } if (rpb.IsEmpty()) { return(Copy()); } if (IsEmpty()) { return(rpb.Copy()); } bool unrestricted = (IsUnrestricted() || rpb.IsUnrestricted()); ResourcePermissionBase result = CreateFromType(this.GetType(), unrestricted); // strangely unrestricted union doesn't process the elements (while intersect does) if (!unrestricted) { foreach (ResourcePermissionBaseEntry entry in _list) { result.AddPermissionAccess(entry); } foreach (ResourcePermissionBaseEntry entry in rpb._list) { // don't add twice if (!result.Exists(entry)) { result.AddPermissionAccess(entry); } } } return(result); }