using LeanCloud.Storage.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace LeanCloud
{
///
/// Provides extension methods for to support
/// Linq-style queries.
///
public static class AVQueryExtensions
{
private static readonly MethodInfo getMethod;
private static readonly MethodInfo stringContains;
private static readonly MethodInfo stringStartsWith;
private static readonly MethodInfo stringEndsWith;
private static readonly MethodInfo containsMethod;
private static readonly MethodInfo notContainsMethod;
private static readonly MethodInfo containsKeyMethod;
private static readonly MethodInfo notContainsKeyMethod;
private static readonly Dictionary functionMappings;
static AVQueryExtensions()
{
getMethod = GetMethod(obj => obj.Get(null)).GetGenericMethodDefinition();
stringContains = GetMethod(str => str.Contains(null));
stringStartsWith = GetMethod(str => str.StartsWith(null));
stringEndsWith = GetMethod(str => str.EndsWith(null));
functionMappings = new Dictionary {
{
stringContains,
GetMethod>(q => q.WhereContains(null, null))
},
{
stringStartsWith,
GetMethod>(q => q.WhereStartsWith(null, null))
},
{
stringEndsWith,
GetMethod>(q => q.WhereEndsWith(null,null))
},
};
containsMethod = GetMethod