/// <summary>Determines whether the specified object is equal to the current object.</summary> /// <param name="obj">The object to compare with the current object.</param> /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns> public override bool Equals(object obj) { if (this.GetType() != obj.GetType()) { return(false); } AuthorizationRule authorizationRule = (AuthorizationRule)obj; if (!string.Equals(this.IssuerName, authorizationRule.IssuerName, StringComparison.OrdinalIgnoreCase) || !string.Equals(this.ClaimType, authorizationRule.ClaimType, StringComparison.OrdinalIgnoreCase) || !string.Equals(this.ClaimValue, authorizationRule.ClaimValue, StringComparison.OrdinalIgnoreCase)) { return(false); } if (this.Rights != null && authorizationRule.Rights == null || this.Rights == null && authorizationRule.Rights != null) { return(false); } if (this.Rights == null || authorizationRule.Rights == null) { return(true); } HashSet <AccessRights> accessRights = new HashSet <AccessRights>(this.Rights); HashSet <AccessRights> accessRights1 = new HashSet <AccessRights>(authorizationRule.Rights); if (accessRights1.Count != accessRights.Count) { return(false); } HashSet <AccessRights> accessRights2 = accessRights1; return(accessRights.All <AccessRights>(new Func <AccessRights, bool>(accessRights2.Contains))); }
/// <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(string.Format("Rights cannot be null, empty or greater than {0}.", 3)); } if (!AuthorizationRule.AreAccessRightsUnique(value)) { throw new ArgumentException("The AccessRights on an Authorization Rule must be unique."); } }