IsValidTargetType() public abstract method

public abstract IsValidTargetType ( Type targetType ) : bool
targetType Type
return bool
Beispiel #1
0
 protected internal AuthorizationRule(System.Security.Principal.IdentityReference identity, int accessMask, bool isInherited, System.Security.AccessControl.InheritanceFlags inheritanceFlags, System.Security.AccessControl.PropagationFlags propagationFlags)
 {
     if (identity == null)
     {
         throw new ArgumentNullException("identity");
     }
     if (accessMask == 0)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_ArgumentZero"), "accessMask");
     }
     if ((inheritanceFlags < System.Security.AccessControl.InheritanceFlags.None) || (inheritanceFlags > (System.Security.AccessControl.InheritanceFlags.ObjectInherit | System.Security.AccessControl.InheritanceFlags.ContainerInherit)))
     {
         throw new ArgumentOutOfRangeException("inheritanceFlags", Environment.GetResourceString("Argument_InvalidEnumValue", new object[] { inheritanceFlags, "InheritanceFlags" }));
     }
     if ((propagationFlags < System.Security.AccessControl.PropagationFlags.None) || (propagationFlags > (System.Security.AccessControl.PropagationFlags.InheritOnly | System.Security.AccessControl.PropagationFlags.NoPropagateInherit)))
     {
         throw new ArgumentOutOfRangeException("propagationFlags", Environment.GetResourceString("Argument_InvalidEnumValue", new object[] { inheritanceFlags, "PropagationFlags" }));
     }
     if (!identity.IsValidTargetType(typeof(SecurityIdentifier)))
     {
         throw new ArgumentException(Environment.GetResourceString("Arg_MustBeIdentityReferenceType"), "identity");
     }
     this._identity         = identity;
     this._accessMask       = accessMask;
     this._isInherited      = isInherited;
     this._inheritanceFlags = inheritanceFlags;
     if (inheritanceFlags != System.Security.AccessControl.InheritanceFlags.None)
     {
         this._propagationFlags = propagationFlags;
     }
     else
     {
         this._propagationFlags = System.Security.AccessControl.PropagationFlags.None;
     }
 }
Beispiel #2
0
        internal protected AuthorizationRule(
            IdentityReference identity,
            int accessMask,
            bool isInherited,
            InheritanceFlags inheritanceFlags,
            PropagationFlags propagationFlags )
        {
            if ( identity == null )
            {
                throw new ArgumentNullException( nameof(identity));
            }

            if ( accessMask == 0 )
            {
                throw new ArgumentException(
                    SR.Argument_ArgumentZero,
nameof(accessMask));
            }

            if ( inheritanceFlags < InheritanceFlags.None || inheritanceFlags > (InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit) )
            {
                throw new ArgumentOutOfRangeException(
nameof(inheritanceFlags),
                    SR.Format( SR.Argument_InvalidEnumValue, inheritanceFlags, "InheritanceFlags" ));
            }

            if ( propagationFlags < PropagationFlags.None || propagationFlags > (PropagationFlags.NoPropagateInherit | PropagationFlags.InheritOnly) )
            {
                throw new ArgumentOutOfRangeException(
nameof(propagationFlags),
                    SR.Format(SR.Argument_InvalidEnumValue, inheritanceFlags, "PropagationFlags"));
            }
            Contract.EndContractBlock();

            if (identity.IsValidTargetType(typeof(SecurityIdentifier)) == false)
            {
                throw new ArgumentException(
                    SR.Arg_MustBeIdentityReferenceType,
nameof(identity));
            }

            _identity = identity;
            _accessMask = accessMask;
            _isInherited = isInherited;
            _inheritanceFlags = inheritanceFlags;

            if ( inheritanceFlags != 0 )
            {
                _propagationFlags = propagationFlags;
            }
            else
            {
                _propagationFlags = 0;
            }
        }