You've already forked linux-packaging-mono
Imported Upstream version 4.0.0~alpha1
Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
29
external/referencesource/System.Web/Util/QueryableUtility.cs
vendored
Normal file
29
external/referencesource/System.Web/Util/QueryableUtility.cs
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace System.Web.Util {
|
||||
internal static class QueryableUtility {
|
||||
private static readonly string[] _orderMethods = new[] { "OrderBy", "ThenBy", "OrderByDescending", "ThenByDescending" };
|
||||
private static readonly MethodInfo[] _methods = typeof(Queryable).GetMethods(BindingFlags.Public | BindingFlags.Static);
|
||||
|
||||
private static MethodInfo GetQueryableMethod(Expression expression) {
|
||||
if (expression.NodeType == ExpressionType.Call) {
|
||||
var call = (MethodCallExpression)expression;
|
||||
if (call.Method.IsStatic && call.Method.DeclaringType == typeof(Queryable)) {
|
||||
return call.Method.GetGenericMethodDefinition();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool IsQueryableMethod(Expression expression, string method) {
|
||||
return _methods.Where(m => m.Name == method).Contains(GetQueryableMethod(expression));
|
||||
}
|
||||
|
||||
public static bool IsOrderingMethod(Expression expression) {
|
||||
return _orderMethods.Any(method => IsQueryableMethod(expression, method));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user