IsUnrestricted() public method

public IsUnrestricted ( ) : bool
return bool
Example #1
0
        public override bool IsSubsetOf(IPermission target)
        {
            // Pattern suggested by security engine
            if (target == null)
            {
                return(access == NetworkInformationAccess.None);
            }

            NetworkInformationPermission other = target as NetworkInformationPermission;

            if (other == null)
            {
                throw new ArgumentException(SR.GetString(SR.net_perm_target), "target");
            }

            if (unrestricted && !other.IsUnrestricted())
            {
                return(false);
            }
            else if ((access & other.access) == access)
            {
                return(true);
            }
            return(false);
        }
        public override bool IsSubsetOf(IPermission target)
        {
            if (target == null)
            {
                return(this.access == NetworkInformationAccess.None);
            }
            NetworkInformationPermission permission = target as NetworkInformationPermission;

            if (permission == null)
            {
                throw new ArgumentException(SR.GetString("net_perm_target"), "target");
            }
            if (this.unrestricted && !permission.IsUnrestricted())
            {
                return(false);
            }
            return((this.access & permission.access) == this.access);
        }
        public override IPermission Union(IPermission target)
        {
            if (target == null)
            {
                return(this.Copy());
            }
            NetworkInformationPermission permission = target as NetworkInformationPermission;

            if (permission == null)
            {
                throw new ArgumentException(SR.GetString("net_perm_target"), "target");
            }
            if (!this.unrestricted && !permission.IsUnrestricted())
            {
                return(new NetworkInformationPermission(this.access | permission.access));
            }
            return(new NetworkInformationPermission(true));
        }
Example #4
0
        public override IPermission Union(IPermission target)
        {
            if (target == null)
            {
                return(this.Copy());
            }
            NetworkInformationPermission other = target as NetworkInformationPermission;

            if (other == null)
            {
                throw new ArgumentException(SR.GetString(SR.net_perm_target), "target");
            }

            if (unrestricted || other.IsUnrestricted())
            {
                return(new NetworkInformationPermission(true));
            }

            return(new NetworkInformationPermission(this.access | other.access));
        }
Example #5
0
        public static void CreatePermission()
        {
            //<Snippet6>
            //<Snippet5>
            //<Snippet2>
            //<Snippet1>
            System.Net.NetworkInformation.NetworkInformationPermission unrestricted =
                new System.Net.NetworkInformation.NetworkInformationPermission(
                    System.Security.Permissions.PermissionState.Unrestricted);
            //</Snippet1>

            Console.WriteLine("Is unrestricted? " + unrestricted.IsUnrestricted());
            //</Snippet2>

            //<Snippet4>
            //<Snippet3>
            System.Net.NetworkInformation.NetworkInformationPermission read =
                new System.Net.NetworkInformation.NetworkInformationPermission(
                    System.Net.NetworkInformation.NetworkInformationAccess.Read);
            //</Snippet3>
            System.Net.NetworkInformation.NetworkInformationPermission copyPermission =
                (System.Net.NetworkInformation.NetworkInformationPermission)read.Copy();
            //</Snippet4>
            System.Net.NetworkInformation.NetworkInformationPermission unionPermission =
                (System.Net.NetworkInformation.NetworkInformationPermission)read.Union(unrestricted);
            Console.WriteLine("Is subset?" + read.IsSubsetOf(unionPermission));
            //</Snippet5>
            System.Net.NetworkInformation.NetworkInformationPermission intersectPermission =
                (System.Net.NetworkInformation.NetworkInformationPermission)read.Intersect(unrestricted);
            //</Snippet6>

            //<Snippet7>
            System.Net.NetworkInformation.NetworkInformationPermission permission =
                new System.Net.NetworkInformation.NetworkInformationPermission(
                    System.Security.Permissions.PermissionState.None);
            permission.AddPermission(
                System.Net.NetworkInformation.NetworkInformationAccess.Read);
            Console.WriteLine("Access is {0}", permission.Access);
            //</Snippet7>
        }