コード例 #1
0
        /// <summary>
        /// Checks the validity of the specified access rights.
        /// </summary>
        /// <param name="value">The access rights to check.</param>
        protected virtual void ValidateRights(IEnumerable <AccessRights> value)
        {
            if (value == null || !value.Any <AccessRights>() || value.Count <AccessRights>() > 3)
            {
                throw new ArgumentException(SRClient.NullEmptyRights((object)3));
            }

            if (!AuthorizationRule.AreAccessRightsUnique(value))
            {
                throw new ArgumentException(SRClient.CannotHaveDuplicateAccessRights);
            }
        }
コード例 #2
0
        internal void Validate()
        {
            if (this.Rights == null || !this.Rights.Any <AccessRights>() || this.Rights.Count <AccessRights>() > 3)
            {
                throw new InvalidDataContractException(SRClient.NullEmptyRights((object)3));
            }

            if (!AuthorizationRule.AreAccessRightsUnique(this.Rights))
            {
                throw new InvalidDataContractException(SRClient.CannotHaveDuplicateAccessRights);
            }

            this.OnValidate();
        }
コード例 #3
0
        /// <summary>
        /// Determines whether the specified object is equal to the current object.
        /// </summary>
        ///
        /// <returns>
        /// true if the specified object is equal to the current object; otherwise, false.
        /// </returns>
        /// <param name="obj">The object to compare with the current object.</param>
        public override bool Equals(Object obj)
        {
            if (!(this.GetType() == obj.GetType()))
            {
                return(false);
            }

            AuthorizationRule comparand = (AuthorizationRule)obj;

            if (!string.Equals(this.IssuerName, comparand.IssuerName, StringComparison.OrdinalIgnoreCase) ||
                !string.Equals(this.ClaimType, comparand.ClaimType, StringComparison.OrdinalIgnoreCase) ||
                !string.Equals(this.ClaimValue, comparand.ClaimValue, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            if ((this.Rights != null && comparand.Rights == null) ||
                (this.Rights == null && comparand.Rights != null))
            {
                return(false);
            }

            if (this.Rights != null && comparand.Rights != null)
            {
                HashSet <AccessRights> thisRights      = new HashSet <AccessRights>(this.Rights);
                HashSet <AccessRights> comparandRights = new HashSet <AccessRights>(comparand.Rights);

                if (comparandRights.Count != thisRights.Count)
                {
                    return(false);
                }

                return(thisRights.All(comparandRights.Contains));
            }

            return(true);
        }