Example #1
0
        /// <summary>
        /// Convert Late Bound Expression to CLR Expression
        /// </summary>
        /// <param name="ex">The Expression</param>
        /// <param name="provider">The IDSQP provider instance</param>
        /// <returns>The converted expression with no latebound methods</returns>
        public static Expression ToClrExpression(Expression ex, IDataServiceQueryProvider provider)
        {
            if (OpenTypeMethodsImplementation == null)
            {
                OpenTypeMethodsImplementation = new DefaultOpenTypeMethodsImplementation();
            }

            if (DSPMethodsImplementation == null)
            {
                DSPMethodsImplementation = new DefaultDSPMethodsImplementation();
            }

            OpenTypeMethodsImplementation.QueryProvider = provider;
            DSPMethodsImplementation.QueryProvider      = provider;
            LateBoundExpressionVisitor visitor = new LateBoundExpressionVisitor(OpenTypeMethodsImplementation, DSPMethodsImplementation);

            return(visitor.Visit(ex));
        }
 protected internal virtual bool ShouldReplaceMethod(MethodInfo method)
 {
     return(!DSPMethodsImplementation.MethodHasImplementation(method));
 }
 /// <summary>
 /// Creates a new instance of LateBoundExpressionVisitor
 /// </summary>
 /// <param name="evaluator">An evaluator class in which expressions will be bound to.</param>
 /// <param name="provider">The provider</param>
 internal LateBoundExpressionVisitor(OpenTypeMethodsImplementation openTypeImplementation, DSPMethodsImplementation dspImplementation)
 {
     this.OpenTypeMethodsImplementation = openTypeImplementation;
     this.DSPMethodsImplementation      = dspImplementation;
 }