// 6.0 TODO: Remove public static bool AllowsNullableReturnType(this IHqlGeneratorForMethod generator, MethodInfo method) { if (generator is IHqlGeneratorForMethodExtended extendedGenerator) { return(extendedGenerator.AllowsNullableReturnType(method)); } return(true); }
/// <summary> /// Should the instance holding the method be ignored? /// </summary> /// <param name="generator">The method's HQL generator.</param> /// <param name="member">The method.</param> /// <returns> /// <see langword="true" /> if the method translation does not depend on the instance to which it /// belongs, <see langword="false" /> otherwise. /// </returns> public static bool IgnoreInstance(this IHqlGeneratorForMethod generator, MemberInfo member) { if (generator is IAllowPreEvaluationHqlGenerator allowPreEvalGenerator) { return(allowPreEvalGenerator.IgnoreInstance(member)); } return(false); }
protected bool GetRuntimeMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) { methodGenerator = null; foreach (var typeGenerator in runtimeMethodHqlGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method))) { methodGenerator = typeGenerator.GetMethodGenerator(method); return true; } return false; }
protected bool GetRuntimeMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) { methodGenerator = null; foreach (var typeGenerator in runtimeMethodHqlGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method))) { methodGenerator = typeGenerator.GetMethodGenerator(method); return(true); } return(false); }
private bool GetMethodGeneratorForType(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) { methodGenerator = null; foreach (var typeGenerator in _typeGenerators.Where(typeGenerator => typeGenerator.SupportsMethod(method))) { methodGenerator = typeGenerator.GetMethodGenerator(method); return true; } return false; }
public static void Merge(this ILinqToHqlGeneratorsRegistry registry, IHqlGeneratorForMethod generator) { if (registry == null) { throw new ArgumentNullException("registry"); } if (generator == null) { throw new ArgumentNullException("generator"); } Array.ForEach(generator.SupportedMethods.ToArray(), method => registry.RegisterGenerator(method, generator)); }
public static void Merge(this ILinqToHqlGeneratorsRegistry registry, IHqlGeneratorForMethod generator) { if (registry == null) { throw new ArgumentNullException("registry"); } if (generator == null) { throw new ArgumentNullException("generator"); } Array.ForEach(generator.SupportedMethods.ToArray(), method=> registry.RegisterGenerator(method, generator)); }
protected bool GetRuntimeMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) { methodGenerator = _cachedRuntimeMethodHqlGenerators.GetOrAdd( method, m => runtimeMethodHqlGenerators .Where(g => g.SupportsMethod(m)) .Select(g => g.GetMethodGenerator(m)) .FirstOrDefault()); return(methodGenerator != null); }
// 6.0 TODO: merge into IHqlGeneratorForMethod /// <summary> /// Should pre-evaluation be allowed for this method? /// </summary> /// <param name="generator">The method's HQL generator.</param> /// <param name="member">The method.</param> /// <param name="factory">The session factory.</param> /// <returns> /// <see langword="true" /> if the method should be evaluated before running the query whenever possible, /// <see langword="false" /> if it must always be translated to the equivalent HQL call. /// </returns> public static bool AllowPreEvaluation( this IHqlGeneratorForMethod generator, MemberInfo member, ISessionFactoryImplementor factory) { if (generator is IAllowPreEvaluationHqlGenerator allowPreEvalGenerator) { return(allowPreEvalGenerator.AllowPreEvaluation(member, factory)); } // By default, everything should be pre-evaluated whenever possible. return(true); }
// 6.0 TODO: Remove public static bool TryGetCollectionParameters( this IHqlGeneratorForMethod generator, MethodCallExpression expression, out ConstantExpression collectionParameter) { if (generator is IHqlGeneratorForMethodExtended extendedGenerator) { return(extendedGenerator.TryGetCollectionParameter(expression, out collectionParameter)); } collectionParameter = null; return(false); }
public virtual bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator) { if (method.IsGenericMethod) { method = method.GetGenericMethodDefinition(); } if (registeredMethods.TryGetValue(method, out generator)) return true; // Not that either. Let's query each type generator to see if it can handle it if (GetRuntimeMethodGenerator(method, out generator)) return true; return false; }
public static void Merge(this ILinqToHqlGeneratorsRegistry registry, IHqlGeneratorForMethod generator) { if (registry == null) { throw new ArgumentNullException("registry"); } if (generator == null) { throw new ArgumentNullException("generator"); } foreach (var method in generator.SupportedMethods) { registry.RegisterGenerator(method, generator); } }
public bool TryGetMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) { if (method.IsGenericMethod) { method = method.GetGenericMethodDefinition(); } if (GetRegisteredMethodGenerator(method, out methodGenerator)) return true; // No method generator registered. Look to see if it's a standard LinqExtensionMethod if (GetStandardLinqExtensionMethodGenerator(method, out methodGenerator)) return true; // Not that either. Let's query each type generator to see if it can handle it if (GetMethodGeneratorForType(method, out methodGenerator)) return true; return false; }
public virtual bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator) { if (method.IsGenericMethod) { method = method.GetGenericMethodDefinition(); } if (registeredMethods.TryGetValue(method, out generator)) { return(true); } // Not that either. Let's query each type generator to see if it can handle it if (GetRuntimeMethodGenerator(method, out generator)) { return(true); } return(false); }
public void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator) { throw new NotImplementedException(); }
public virtual void RegisterGenerator(MethodInfo method, IHqlGeneratorForMethod generator) { registeredMethods.Add(method, generator); }
private bool GetStandardLinqExtensionMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) { methodGenerator = null; var attr = method.GetCustomAttributes(typeof(LinqExtensionMethodAttribute), false); if (attr.Length == 1) { // It is methodGenerator = new HqlGeneratorForExtensionMethod((LinqExtensionMethodAttribute)attr[0], method); return true; } return false; }
public bool TryGetGenerator(MethodInfo method, out IHqlGeneratorForMethod generator) { throw new NotImplementedException(); }
private bool GetRegisteredMethodGenerator(MethodInfo method, out IHqlGeneratorForMethod methodGenerator) { if (_registeredMethods.TryGetValue(method, out methodGenerator)) { return true; } return false; }
public void RegisterMethodGenerator(MethodInfo method, IHqlGeneratorForMethod generator) { _registeredMethods.Add(method, generator); }