public IPermission Union(IPermission target) { // Handle the easy cases first. if (target == null) { return(Copy()); } else if (!(target is PrincipalPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if (IsUnrestricted() || ((PrincipalPermission)target).IsUnrestricted()) { return(new PrincipalPermission (PermissionState.Unrestricted)); } // Form the union of the two lists. PrincipalPermission perm = new PrincipalPermission(this, true); PrincipalInfo other, newPrin; foreach (PrincipalInfo prin in ((PrincipalPermission)target) .principals) { other = perm.Find(prin.name, prin.role); if (other == null) { newPrin = new PrincipalInfo(); newPrin.name = prin.name; newPrin.role = prin.role; newPrin.isAuthenticated = prin.isAuthenticated; perm.principals.Add(newPrin); } else { other.isAuthenticated = (prin.isAuthenticated || other.isAuthenticated); } } return(perm); }
public IPermission Union(IPermission target) { // Handle the easy cases first. if(target == null) { return Copy(); } else if(!(target is PrincipalPermission)) { throw new ArgumentException(_("Arg_PermissionMismatch")); } else if(IsUnrestricted() || ((PrincipalPermission)target).IsUnrestricted()) { return new PrincipalPermission (PermissionState.Unrestricted); } // Form the union of the two lists. PrincipalPermission perm = new PrincipalPermission(this, true); PrincipalInfo other, newPrin; foreach(PrincipalInfo prin in ((PrincipalPermission)target) .principals) { other = perm.Find(prin.name, prin.role); if(other == null) { newPrin = new PrincipalInfo(); newPrin.name = prin.name; newPrin.role = prin.role; newPrin.isAuthenticated = prin.isAuthenticated; perm.principals.Add(newPrin); } else { other.isAuthenticated = (prin.isAuthenticated || other.isAuthenticated); } } return perm; }