IsUnrestricted() public method

public IsUnrestricted ( ) : bool
return bool
        public override bool IsSubsetOf(IPermission target)
        {
            if (target == null)
            {
                // do not use Cast - different permissions (and earlier Fx) return false :-/
                return(true);
            }

            ResourcePermissionBase rpb = (target as ResourcePermissionBase);

            if (rpb == null)
            {
                return(false);
            }
            if (rpb.IsUnrestricted())
            {
                return(true);
            }
            if (IsUnrestricted())
            {
                return(rpb.IsUnrestricted());
            }
            foreach (ResourcePermissionBaseEntry entry in _list)
            {
                if (!rpb.Exists(entry))
                {
                    return(false);
                }
            }
            return(true);
        }
        public override IPermission Union(IPermission target)
        {
            if (target == null)
            {
                return(this.Copy());
            }
            if (target.GetType() != base.GetType())
            {
                throw new ArgumentException(SR.GetString("PermissionTypeMismatch"), "target");
            }
            ResourcePermissionBase base2 = (ResourcePermissionBase)target;
            ResourcePermissionBase base3 = null;

            if (this.IsUnrestricted() || base2.IsUnrestricted())
            {
                base3 = this.CreateInstance();
                base3.isUnrestricted = true;
                return(base3);
            }
            Hashtable hashtable = (Hashtable)this.UnionOfContents(this.rootTable, base2.rootTable);

            if (hashtable != null)
            {
                base3           = this.CreateInstance();
                base3.rootTable = hashtable;
            }
            return(base3);
        }
Esempio n. 3
0
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override IPermission Union(IPermission target)
        {
            if (target == null)
            {
                return(this.Copy());
            }

            if (target.GetType() != this.GetType())
            {
                throw new ArgumentException(SR.GetString(SR.PermissionTypeMismatch), "target");
            }

            ResourcePermissionBase targetPermission = (ResourcePermissionBase)target;
            ResourcePermissionBase newPermission    = null;

            if (this.IsUnrestricted() || targetPermission.IsUnrestricted())
            {
                newPermission = CreateInstance();
                newPermission.isUnrestricted = true;
            }
            else
            {
                Hashtable newPermissionRootTable = (Hashtable)UnionOfContents(this.rootTable, targetPermission.rootTable);
                if (newPermissionRootTable != null)
                {
                    newPermission           = CreateInstance();
                    newPermission.rootTable = newPermissionRootTable;
                }
            }
            return(newPermission);
        }
Esempio n. 4
0
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override bool IsSubsetOf(IPermission target)
        {
            if (target == null)
            {
                return(IsEmpty);
            }

            if (target.GetType() != this.GetType())
            {
                return(false);
            }

            ResourcePermissionBase targetPermission = (ResourcePermissionBase)target;

            if (targetPermission.IsUnrestricted())
            {
                return(true);
            }
            else if (this.IsUnrestricted())
            {
                return(false);
            }

            return(IsContentSubset(this.rootTable, targetPermission.rootTable));
        }
Esempio n. 5
0
        /// <include file='doc\ResourcePermissionBase.uex' path='docs/doc[@for="ResourcePermissionBase.Intersect"]/*' />
        /// <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("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);
        }
        public override IPermission Intersect(IPermission target)
        {
            ResourcePermissionBase rpb = Cast(target);

            if (rpb == null)
            {
                return(null);
            }

            bool su = this.IsUnrestricted();
            bool tu = rpb.IsUnrestricted();

            // if one is empty we return null (unless the other one is unrestricted)
            if (IsEmpty() && !tu)
            {
                return(null);
            }
            if (rpb.IsEmpty() && !su)
            {
                return(null);
            }

            ResourcePermissionBase result = CreateFromType(this.GetType(), (su && tu));

            foreach (ResourcePermissionBaseEntry entry in _list)
            {
                if (tu || rpb.Exists(entry))
                {
                    result.AddPermissionAccess(entry);
                }
            }
            foreach (ResourcePermissionBaseEntry entry in rpb._list)
            {
                // don't add twice
                if ((su || this.Exists(entry)) && !result.Exists(entry))
                {
                    result.AddPermissionAccess(entry);
                }
            }
            return(result);
        }