Skip to content

Commit 65908d1

Browse files
authored
Do not use runtime method generator
1 parent 1e03044 commit 65908d1

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/NHibernate/Linq/Functions/HasFlagGenerator.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
1-
using System;
1+
using System;
22
using System.Collections.ObjectModel;
33
using System.Linq.Expressions;
44
using System.Reflection;
55
using NHibernate.Hql.Ast;
66
using NHibernate.Linq.Visitors;
7+
using NHibernate.Util;
78

89
namespace NHibernate.Linq.Functions
910
{
10-
internal class HasFlagGenerator : BaseHqlGeneratorForMethod, IRuntimeMethodHqlGenerator
11+
internal class HasFlagGenerator : BaseHqlGeneratorForMethod
1112
{
12-
private const string _bitAndFunctionName = "band";
13-
14-
public bool SupportsMethod(MethodInfo method)
15-
{
16-
return method.Name == nameof(Enum.HasFlag) && method.DeclaringType == typeof(Enum);
17-
}
18-
19-
public IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
13+
internal HasFlagGenerator()
2014
{
21-
return this;
15+
SupportsMethod = new []
16+
{
17+
ReflectHelper.FastGetMethod(Enum.HasFlag, default(Enum))
18+
};
2219
}
2320

2421
public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
2522
{
2623
return treeBuilder.Equality(
2724
treeBuilder.MethodCall(
28-
_bitAndFunctionName,
29-
visitor.Visit(targetObject).AsExpression(),
30-
visitor.Visit(arguments[0]).AsExpression()),
25+
"band",
26+
visitor.Visit(targetObject).AsExpression(),
27+
visitor.Visit(arguments[0]).AsExpression()),
3128
visitor.Visit(arguments[0]).AsExpression());
3229
}
3330
}

0 commit comments

Comments
 (0)