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/Hasher.cs

26 lines
514 B

using System.Linq.Expressions;
using Connected.Expressions.Visitors;
namespace Connected.Expressions.Translation;
internal sealed class Hasher : DatabaseVisitor
{
private int _hc;
internal static int ComputeHash(Expression expression)
{
var hasher = new Hasher();
hasher.Visit(expression);
return hasher._hc;
}
protected override Expression VisitConstant(ConstantExpression expression)
{
_hc += (expression.Value is not null) ? expression.Value.GetHashCode() : 0;
return expression;
}
}