Exemple #1
0
        public virtual PermissionSet Union(PermissionSet other)
#endif
        {
            if (other == null)
            {
                return(this.Copy());
            }

            PermissionSet copy = null;

            if (this.IsUnrestricted() || other.IsUnrestricted())
            {
#if NET_2_0
                // there are no child elements in unrestricted permission sets
                return(new PermissionSet(PermissionState.Unrestricted));
#else
                copy = this.Copy();
                // so we keep the "right" type (e.g. NamedPermissionSet)
                copy.Clear();
                copy.state = PermissionState.Unrestricted;
                // copy all permissions that do not implement IUnrestrictedPermission
                foreach (IPermission p in this.list)
                {
                    if (!(p is IUnrestrictedPermission))
                    {
                        copy.AddPermission(p);
                    }
                }
                foreach (IPermission p in other.list)
                {
                    if (!(p is IUnrestrictedPermission))
                    {
                        copy.AddPermission(p);
                    }
                }
#endif
            }
            else
            {
                copy = this.Copy();
                // PermissionState.None -> copy all permissions
                foreach (IPermission p in other.list)
                {
                    copy.AddPermission(p);
                }
            }
            return(copy);
        }