public bool Equals(ZeroToken other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } bool audEqual = Audiences.Count == other.Audiences.Count && Audiences.All(other.Audiences.Contains); bool claimsEqual = Claims.Count == other.Claims.Count && Claims.All(other.Claims.Contains); bool result = audEqual && string.Equals(Issuer, other.Issuer) && CreationTime.Equals(other.CreationTime) && Lifetime == other.Lifetime && string.Equals(Type, other.Type) && string.Equals(ClientId, other.ClientId) && AccessTokenType == other.AccessTokenType && claimsEqual && Version == other.Version; return(result); }
public bool Equals(IdentityResource other) { if (ReferenceEquals(null, other)) { return(false); } if (IdentityProviderName != other.IdentityProviderName) { return(false); } return(Claims.All(kvp => { if (!kvp.Value.IsIdentifyingClaim || kvp.Value.IsServerSideOnly) { return true; } if (!other.Claims.ContainsKey(kvp.Key)) { return false; } var existingClaimValue = kvp.Value.Value; var bothClaimsAreNullOrWhitespace = string.IsNullOrWhiteSpace(existingClaimValue) && string.IsNullOrWhiteSpace(other.Claims[kvp.Key].Value); var existingClaimHasValueAndMatches = !string.IsNullOrWhiteSpace(existingClaimValue) && existingClaimValue.Equals(other.Claims[kvp.Key].Value, StringComparison.OrdinalIgnoreCase); return bothClaimsAreNullOrWhitespace || existingClaimHasValueAndMatches; })); }