Esempio n. 1
0
 public MyLinqToHqlGeneratorsRegistry() : base()
 {
     RegisterGenerator(ReflectHelper.GetMethodDefinition(() => MyLinqExtensions.IsLike(null, null)),
                       new IsLikeGenerator());
     RegisterGenerator(ReflectHelper.GetMethodDefinition(() => new object().Equals(null)), new ObjectEqualsGenerator());
     RegisterGenerator(ReflectHelper.GetMethodDefinition(() => MyLinqExtensions.GetTime(default(DateTime))), new GetTimeGenerator());
 }
Esempio n. 2
0
 public DecimalNegateGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition(() => decimal.Negate(default(decimal)))
     };
 }
Esempio n. 3
0
        public NHibernateNodeTypeProvider()
        {
            var methodInfoRegistry = new MethodInfoBasedNodeTypeRegistry();

            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.Fetch <object, object>(null, null)) },
                typeof(FetchOneExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.FetchMany <object, object>(null, null)) },
                typeof(FetchManyExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetch <object, object, object>(null, null)) },
                typeof(ThenFetchOneExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetchMany <object, object, object>(null, null)) },
                typeof(ThenFetchManyExpressionNode));

            methodInfoRegistry.Register(
                new[]
            {
                ReflectHelper.GetMethodDefinition(() => Queryable.AsQueryable(null)),
                ReflectHelper.GetMethodDefinition(() => Queryable.AsQueryable <object>(null)),
            }, typeof(AsQueryableExpressionNode)
                );

            methodInfoRegistry.Register(new[] { LinqExtensionMethods.SetOptionsDefinition }, typeof(OptionsExpressionNode));

            var nodeTypeProvider = ExpressionTreeParser.CreateDefaultNodeTypeProvider();

            nodeTypeProvider.InnerProviders.Add(methodInfoRegistry);
            defaultNodeTypeProvider = nodeTypeProvider;
        }
Esempio n. 4
0
 public StartsWithIgnoreCaseAndDiacriticsHqlGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition(() => StringExtensions.StartsWithIgnoreCaseAndDiacritics(null, null))
     };
 }
Esempio n. 5
0
 public TrimGenerator()
 {
     SupportedMethods = new[] {
         ReflectHelper.GetMethodDefinition(() => TrimExtensions.TrimLeading(null, null)),
         ReflectHelper.GetMethodDefinition(() => TrimExtensions.TrimTrailing(null, null)),
     };
 }
 public IsNullGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition <Geometry>(g => g.IsNull())
     };
 }
 static LinqExtensions()
 {
     EnumerableToListMethod = ReflectHelper.GetMethodDefinition(() => Enumerable.ToList(new object[0]))
                              .GetGenericMethodDefinition();
     IncludeMethod = ReflectHelper.GetMethodDefinition(() => Include(default(IQueryable <object>), ""))
                     .GetGenericMethodDefinition();
 }
Esempio n. 8
0
 public DecimalSubtractGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition(() => decimal.Subtract(default(decimal), default(decimal)))
     };
 }
Esempio n. 9
0
        static IncludeQueryProvider()
        {
            CreateQueryMethod =
                ReflectHelper.GetMethodDefinition((INhQueryProvider p) => p.CreateQuery <object>(null));
            ExecuteInternalMethod =
                ReflectHelper.GetMethodDefinition((IncludeQueryProvider p) => p.ExecuteInternal <object>(null, null));
            ExecuteInternalAsyncMethod =
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                ReflectHelper.GetMethodDefinition((IncludeQueryProvider p) => p.ExecuteInternalAsync <object>(null, null, default));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

            FetchMethod =
                ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.Fetch <object, object>(null, null));
            FetchManyMethod =
                ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.FetchMany <object, object>(null, null));
            ThenFetchMethod =
                ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetch <object, object, object>(null, null));
            ThenFetchManyMethod =
                ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetchMany <object, object, object>(null, null));

            WhereMethod    = ReflectHelper.GetMethodDefinition(() => Queryable.Where <object>(null, o => true));
            ContainsMethod = ReflectHelper.GetMethodDefinition(() => Queryable.Contains <object>(null, null));

            var param       = Expression.Parameter(typeof(DefaultQueryProvider));
            var sessionProp = typeof(DefaultQueryProvider).GetProperty("Session",
                                                                       BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
            if (sessionProp == null)
            {
                throw new InvalidOperationException($"{typeof(DefaultQueryProvider)} does not have a Session property.");
            }
            SessionProvider = Expression.Lambda <Func <DefaultQueryProvider, ISessionImplementor> >(
                Expression.Property(param, sessionProp), param).Compile();
        }
Esempio n. 10
0
        public EqualsGenerator()
        {
            SupportedMethods = new[]
            {
                ReflectHelper.GetMethodDefinition(() => string.Equals(default(string), default(string))),
                ReflectHelper.GetMethodDefinition <string>(x => x.Equals(x)),
                ReflectHelper.GetMethodDefinition <char>(x => x.Equals(x)),

                ReflectHelper.GetMethodDefinition <sbyte>(x => x.Equals(x)),
                ReflectHelper.GetMethodDefinition <byte>(x => x.Equals(x)),

                ReflectHelper.GetMethodDefinition <short>(x => x.Equals(x)),
                ReflectHelper.GetMethodDefinition <ushort>(x => x.Equals(x)),

                ReflectHelper.GetMethodDefinition <int>(x => x.Equals(x)),
                ReflectHelper.GetMethodDefinition <uint>(x => x.Equals(x)),

                ReflectHelper.GetMethodDefinition <long>(x => x.Equals(x)),
                ReflectHelper.GetMethodDefinition <ulong>(x => x.Equals(x)),

                ReflectHelper.GetMethodDefinition <float>(x => x.Equals(x)),
                ReflectHelper.GetMethodDefinition <double>(x => x.Equals(x)),
                ReflectHelper.GetMethodDefinition <decimal>(x => x.Equals(x)),

                ReflectHelper.GetMethodDefinition <Guid>(x => x.Equals(x)),
                ReflectHelper.GetMethodDefinition <DateTime>(x => x.Equals(x)),
                ReflectHelper.GetMethodDefinition <DateTimeOffset>(x => x.Equals(x)),
                ReflectHelper.GetMethodDefinition <bool>(x => x.Equals(default(bool)))
            };
        }
Esempio n. 11
0
 public DecimalRemainderGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition(() => decimal.Remainder(default(decimal), default(decimal)))
     };
 }
Esempio n. 12
0
        public NHibernateNodeTypeProvider()
        {
            var methodInfoRegistry = new MethodInfoBasedNodeTypeRegistry();

            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.Fetch <object, object>(null, null)) },
                typeof(FetchOneExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.FetchMany <object, object>(null, null)) },
                typeof(FetchManyExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetch <object, object, object>(null, null)) },
                typeof(ThenFetchOneExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetchMany <object, object, object>(null, null)) },
                typeof(ThenFetchManyExpressionNode));
            methodInfoRegistry.Register(
                new[]
            {
                ReflectHelper.GetMethodDefinition(() => default(IQueryable <object>).WithLock(LockMode.Read)),
                ReflectHelper.GetMethodDefinition(() => default(IEnumerable <object>).WithLock(LockMode.Read))
            },
                typeof(LockExpressionNode));

            var nodeTypeProvider = ExpressionTreeParser.CreateDefaultNodeTypeProvider();

            nodeTypeProvider.InnerProviders.Add(methodInfoRegistry);
            defaultNodeTypeProvider = nodeTypeProvider;
        }
Esempio n. 13
0
 public DecimalMultiplyGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition(() => decimal.Multiply(default(decimal), default(decimal)))
     };
 }
Esempio n. 14
0
 public ToUpperGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition <string>(x => x.ToUpper()),
         ReflectHelper.GetMethodDefinition <string>(x => x.ToUpperInvariant()),
     };
 }
Esempio n. 15
0
 public MinHqlGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectionCache.QueryableMethods.MinDefinition,
         ReflectHelper.GetMethodDefinition(() => Enumerable.Min <object>(null))
     };
 }
Esempio n. 16
0
 public DynamicPropertyGenerator()
 {
     // just registering for string here, but in a real implementation we'd be doing a runtime generator
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition(() => ObjectExtensions.GetProperty <string>(null, null))
     };
 }
Esempio n. 17
0
 public ConvertToBooleanGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition <string>(s => Boolean.Parse(s)),
         ReflectHelper.GetMethodDefinition <string>(o => Convert.ToBoolean(o))
     };
 }
Esempio n. 18
0
 public CollectionContainsGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition(() => Queryable.Contains <object>(null, null)),
         ReflectHelper.GetMethodDefinition(() => Enumerable.Contains <object>(null, null))
     };
 }
Esempio n. 19
0
 public SubStringGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition <string>(s => s.Substring(0)),
         ReflectHelper.GetMethodDefinition <string>(s => s.Substring(0, 0))
     };
 }
Esempio n. 20
0
 public ListIndexerGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition(() => Enumerable.ElementAt <object>(null, 0)),
         ReflectHelper.GetMethodDefinition(() => Queryable.ElementAt <object>(null, 0))
     };
 }
Esempio n. 21
0
 public ConvertToDateTimeGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition <string>(s => DateTime.Parse(s)),
         ReflectHelper.GetMethodDefinition <string>(o => Convert.ToDateTime(o))
     };
 }
Esempio n. 22
0
 public ReplaceGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition <string>(s => s.Replace(' ', ' ')),
         ReflectHelper.GetMethodDefinition <string>(s => s.Replace("", ""))
     };
 }
Esempio n. 23
0
 public AllHqlGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition(() => Queryable.All <object>(null, null)),
         ReflectHelper.GetMethodDefinition(() => Enumerable.All <object>(null, null))
     };
 }
 public TruncateGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition(() => Math.Truncate(default(decimal))),
         ReflectHelper.GetMethodDefinition(() => Math.Truncate(default(double))),
         ReflectHelper.GetMethodDefinition(() => decimal.Truncate(default(decimal)))
     };
 }
Esempio n. 25
0
 public AnyHqlGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectionCache.QueryableMethods.AnyDefinition,
         ReflectionCache.QueryableMethods.AnyWithPredicateDefinition,
         ReflectHelper.GetMethodDefinition(() => Enumerable.Any <object>(null)),
         ReflectHelper.GetMethodDefinition(() => Enumerable.Any <object>(null, null))
     };
 }
Esempio n. 26
0
 public IndexOfGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition <string>(s => s.IndexOf(' ')),
         ReflectHelper.GetMethodDefinition <string>(s => s.IndexOf(" ")),
         ReflectHelper.GetMethodDefinition <string>(s => s.IndexOf(' ', 0)),
         ReflectHelper.GetMethodDefinition <string>(s => s.IndexOf(" ", 0))
     };
 }
Esempio n. 27
0
 public TrimGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition <string>(s => s.Trim()),
         ReflectHelper.GetMethodDefinition <string>(s => s.Trim('a')),
         ReflectHelper.GetMethodDefinition <string>(s => s.TrimStart('a')),
         ReflectHelper.GetMethodDefinition <string>(s => s.TrimEnd('a'))
     };
 }
Esempio n. 28
0
 public InGenerator()
 {
     SupportedMethods = new[]
     {
         ReflectHelper.GetMethodDefinition(() => ObjectExtesions.In(null, (object[])null)),
         ReflectHelper.GetMethodDefinition(() => ObjectExtesions.In <object>(null, (IQueryable <object>)null)),
         ReflectHelper.GetMethodDefinition(() => ObjectExtesions.NotIn <object>(null, (object[])null)),
         ReflectHelper.GetMethodDefinition(() => ObjectExtesions.NotIn <object>(null, (IQueryable <object>)null))
     };
 }
Esempio n. 29
0
 public DateTimeAddGenerator()
 {
     SupportedMethods = new[] {
         ReflectHelper.GetMethodDefinition <DateTime>(d => d.AddSeconds((double)0)),
         ReflectHelper.GetMethodDefinition <DateTime>(d => d.AddMinutes((double)0)),
         ReflectHelper.GetMethodDefinition <DateTime>(d => d.AddHours((double)0)),
         ReflectHelper.GetMethodDefinition <DateTime>(d => d.AddDays((double)0)),
         ReflectHelper.GetMethodDefinition <DateTime>(d => d.AddMonths((int)0)),
         ReflectHelper.GetMethodDefinition <DateTime>(d => d.AddYears((int)0)),
     };
 }
Esempio n. 30
0
        public ReplaceGenerator()
        {
            SupportedMethods = new[]
            {
                ReflectHelper.GetMethodDefinition <string>(s => s.Replace(' ', ' ')),
                ReflectHelper.GetMethodDefinition <string>(s => s.Replace("", "")),
#if NETCOREAPP2_0
                MethodWithComparer,
#endif
            };
        }