You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Expressions/Translation/HashedExpression.cs

34 lines
755 B

using System.Linq.Expressions;
using Connected.Expressions.Comparers;
namespace Connected.Expressions.Translation;
internal readonly struct HashedExpression : IEquatable<HashedExpression>
{
private readonly Expression _expression;
private readonly int _hashCode;
public HashedExpression(Expression expression)
{
_expression = expression;
_hashCode = Hasher.ComputeHash(expression);
}
public override bool Equals(object? obj)
{
if (obj is not HashedExpression)
return false;
return Equals((HashedExpression)obj);
}
public bool Equals(HashedExpression other)
{
return _hashCode == other._hashCode && DatabaseComparer.AreEqual(_expression, other._expression);
}
public override int GetHashCode()
{
return _hashCode;
}
}