Пример #1
0
        public override bool IsSubsetOf(IPermission target)
        {
            bool flag;

            if (target == null)
            {
                return(!this.unrestricted);
            }
            try
            {
                DistributedTransactionPermission permission = (DistributedTransactionPermission)target;
                if (!this.unrestricted)
                {
                    return(true);
                }
                if (permission.unrestricted)
                {
                    return(true);
                }
                flag = false;
            }
            catch (InvalidCastException)
            {
                throw new ArgumentException(System.Transactions.SR.GetString("ArgumentWrongType"), "target");
            }
            return(flag);
        }
        public override bool IsSubsetOf(IPermission target)
        {
            if (null == target)
            {
                return(!this.unrestricted);
            }
            try
            {
                DistributedTransactionPermission passedPermission = (DistributedTransactionPermission)target;
                // If the current permission is "none" it will always be a subset of
                // any other DistributedTransactionPermission.
                if (!this.unrestricted)
                {
                    return(true);
                }

                // At this point, we know the current permission is unrestricted.  If
                // the passed permission is unrestricted, we have a subset.
                if (passedPermission.unrestricted)
                {
                    return(true);
                }

                // If we get here, the current permission is unrestricted, but the passed
                // permission is "none", so the current permission is NOT a subset of
                // the passed permission.
                return(false);
            }
            catch (InvalidCastException)
            {
                throw new ArgumentException(SR.GetString(SR.ArgumentWrongType), "target");
            }
        }
 public override IPermission Copy()
 {
     DistributedTransactionPermission permission = new DistributedTransactionPermission(PermissionState.None);
     if (this.IsUnrestricted())
     {
         permission.unrestricted = true;
         return permission;
     }
     permission.unrestricted = false;
     return permission;
 }
Пример #4
0
        public override IPermission Copy()
        {
            DistributedTransactionPermission permission = new DistributedTransactionPermission(PermissionState.None);

            if (this.IsUnrestricted())
            {
                permission.unrestricted = true;
                return(permission);
            }
            permission.unrestricted = false;
            return(permission);
        }
        //Define the rest of your custom permission here. You must 
        //implement IsUnrestricted, and override Copy, Intersect, 
        //IsSubsetOf, ToXML, and FromXML.

        public override IPermission Copy()
        {
            DistributedTransactionPermission copy = new DistributedTransactionPermission(PermissionState.None);

            if (this.IsUnrestricted())
            {
                copy.unrestricted = true;
            }
            else
            {
                copy.unrestricted = false;
            }
            return copy;
        }
        //Define the rest of your custom permission here. You must
        //implement IsUnrestricted, and override Copy, Intersect,
        //IsSubsetOf, ToXML, and FromXML.

        public override IPermission Copy()
        {
            DistributedTransactionPermission copy = new DistributedTransactionPermission(PermissionState.None);

            if (this.IsUnrestricted())
            {
                copy.unrestricted = true;
            }
            else
            {
                copy.unrestricted = false;
            }
            return(copy);
        }
        public override IPermission Intersect(IPermission target)
        {
            try
            {
                if (null == target)
                {
                    return(null);
                }
                DistributedTransactionPermission passedPermission = (DistributedTransactionPermission)target;

                if (!passedPermission.IsUnrestricted())
                {
                    return(passedPermission);
                }
                return(this.Copy());
            }
            catch (InvalidCastException)
            {
                throw new ArgumentException(SR.GetString(SR.ArgumentWrongType), "target");
            }
        }
Пример #8
0
        public override IPermission Intersect(IPermission target)
        {
            IPermission permission;

            try
            {
                if (target == null)
                {
                    return(null);
                }
                DistributedTransactionPermission permission2 = (DistributedTransactionPermission)target;
                if (!permission2.IsUnrestricted())
                {
                    return(permission2);
                }
                permission = this.Copy();
            }
            catch (InvalidCastException)
            {
                throw new ArgumentException(System.Transactions.SR.GetString("ArgumentWrongType"), "target");
            }
            return(permission);
        }