Ejemplo n.º 1
0
 //
 // Summary:
 //     Visits the children of the System.Linq.Expressions.InvocationExpression.
 //
 // Parameters:
 //   node:
 //     The expression to visit.
 //
 // Returns:
 //     The modified expression, if it or any subexpression was modified; otherwise,
 //     returns the original expression.
 protected override Expression VisitInvocation(InvocationExpression node)
 {
     Console.WriteLine("VisitInvocation:");
     Console.WriteLine('\t' + node.GetType().ToString());
     Console.WriteLine('\t' + node.ToString());
     return(base.VisitInvocation(node));
 }
Ejemplo n.º 2
0
        public static void ToStringTest()
        {
            InvocationExpression e1 = Expression.Invoke(Expression.Parameter(typeof(Action), "f"));

            Assert.Equal("Invoke(f)", e1.ToString());

            InvocationExpression e2 = Expression.Invoke(Expression.Parameter(typeof(Action <int>), "f"), Expression.Parameter(typeof(int), "x"));

            Assert.Equal("Invoke(f, x)", e2.ToString());
        }
Ejemplo n.º 3
0
            public static string EvaluateMethodCoupling(InvocationExpression expression, MethodProperties meth)
            {
                Console.WriteLine(expression.ToString());

                meth.EfferentCoupling++;

                StringBuilder    calleeName = new StringBuilder();
                List <string>    paramList  = new List <string>();
                MethodProperties methCallee = null;

                lock (coupleLock)
                {
                    if (expression.TargetObject is MemberReferenceExpression)
                    {
                        calleeName.Append(ExtractCalleeFullName((MemberReferenceExpression)(expression.TargetObject), meth));
                        paramList = ExtractParamList(expression, meth);

                        try {
                            methCallee = ComplexityMetrics.ProjProp.GetMethodReference(calleeName.ToString(), paramList);
                            methCallee.AfferentCoupling++;
                        } catch (Exception e) {
                            Console.WriteLine(e.ToString());
                        }
                    }
                    else if (expression.TargetObject is IdentifierExpression)
                    {
                        calleeName.Append(((IdentifierExpression)expression.TargetObject).Identifier);
                        paramList = ExtractParamList(expression, meth);

                        try {
                            Console.WriteLine(calleeName.ToString());
                            methCallee = ComplexityMetrics.ProjProp.GetMethodReference(calleeName.ToString(), paramList);
                            methCallee.AfferentCoupling++;
                        } catch (Exception e) {
                            Console.WriteLine(e.ToString());
                        }
                    }
                }
                return(methCallee.Method.ReturnType.FullName);
            }
Ejemplo n.º 4
0
			public static string EvaluateMethodCoupling(InvocationExpression expression, MethodProperties meth)
			{
				Console.WriteLine(expression.ToString());
				
				meth.EfferentCoupling++;
				
				StringBuilder calleeName = new StringBuilder();
				List<string> paramList = new List<string>();
				MethodProperties methCallee = null;
				lock(coupleLock)
				{
					if(expression.Target is MemberReferenceExpression) {
					
			   			calleeName.Append(ExtractCalleeFullName((MemberReferenceExpression)(expression.Target), meth));
						paramList = ExtractParamList(expression, meth);
					
						try {
//							methCallee = ComplexityMetrics.ProjProp.GetMethodReference(calleeName.ToString(), paramList);
							methCallee.AfferentCoupling++;
						} catch (Exception e) {
							Console.WriteLine(e.ToString());
						}
					
					} else if (expression.Target is IdentifierExpression) {
					
						calleeName.Append(((IdentifierExpression)expression.Target).Identifier);
						paramList = ExtractParamList(expression, meth);
					
						try {
							Console.WriteLine(calleeName.ToString());
//							methCallee = ComplexityMetrics.ProjProp.GetMethodReference(calleeName.ToString(), paramList);
							methCallee.AfferentCoupling++;
						} catch (Exception e) {
							Console.WriteLine(e.ToString());
						}
					} 
				}
				return methCallee.Method.ReturnType.ToString ();
			}
 public override string ToString()
 {
     return(InvocationExpression?.ToString() ?? base.ToString());
 }
Ejemplo n.º 6
0
            internal override Expression VisitInvocation(InvocationExpression iv)
            {
                if (ClientType.CheckElementTypeIsEntity(iv.Expression.Type) || IsCollectionProducingExpression(iv.Expression) ||
                    iv.Arguments.Any(a => ClientType.CheckElementTypeIsEntity(a.Type) || IsCollectionProducingExpression(a)))
                {
                    throw new NotSupportedException(Strings.ALinq_ExpressionNotSupportedInProjection(this.type, iv.ToString()));
                }

                return(base.VisitInvocation(iv));
            }
Ejemplo n.º 7
0
 internal override Expression VisitInvocation(InvocationExpression iv)
 {
     throw new NotSupportedException(Strings.ALinq_ExpressionNotSupportedInProjectionToEntity(this.type, iv.ToString()));
 }
Ejemplo n.º 8
0
 /// <summary>访问子内容为: <see cref="T:System.Linq.Expressions.InvocationExpression"></see>.</summary>
 /// <param name="node">被访问的表达式</param>
 /// <returns>The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.</returns>
 protected override Expression VisitInvocation(InvocationExpression node)
 {
     Log(node.ToString());
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
            internal override Expression VisitInvocation(InvocationExpression iv)
            {
                if (CommonUtil.IsClientType(iv.Expression.Type) ||
                    iv.Arguments.Any(a => CommonUtil.IsClientType(a.Type)))
                {
                    throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, SR.ALinqExpressionNotSupportedInProjection, this.type, iv.ToString()));
                }

                return(base.VisitInvocation(iv));
            }
Ejemplo n.º 10
0
 internal override Expression VisitInvocation(InvocationExpression iv)
 {
     throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, SR.ALinqExpressionNotSupportedInProjectionToEntity, this.type, iv.ToString()));
 }
Ejemplo n.º 11
0
 internal override Expression VisitInvocation(InvocationExpression iv)
 {
     if ((ClientTypeUtil.TypeOrElementTypeIsEntity(iv.Expression.Type) || ProjectionAnalyzer.IsCollectionProducingExpression(iv.Expression)) || iv.Arguments.Any <Expression>(delegate(Expression a) {
         if (!ClientTypeUtil.TypeOrElementTypeIsEntity(a.Type))
         {
             return(ProjectionAnalyzer.IsCollectionProducingExpression(a));
         }
         return(true);
     }))
     {
         throw new NotSupportedException(System.Data.Services.Client.Strings.ALinq_ExpressionNotSupportedInProjection(this.type, iv.ToString()));
     }
     return(base.VisitInvocation(iv));
 }
Ejemplo n.º 12
0
 protected virtual Expression VisitInvocation(InvocationExpression node)
 {
     Console.WriteLine("VisitInvocation:" + node.ToString());
     return(node);
 }
Ejemplo n.º 13
0
            /// <summary>
            /// We are doing an inline call to a lambda expression.
            /// </summary>
            /// <param name="expression"></param>
            /// <returns></returns>
            protected override Expression VisitInvocation(InvocationExpression expression)
            {
                ///
                /// Declare all the parameters for lookup.
                ///

                if (!(expression.Expression is LambdaExpression))
                {
                    throw new NotImplementedException("Do not know how to invoke a non-lambda call like '" + expression.ToString() + "'");
                }

                var lambda = expression.Expression as LambdaExpression;

                var paramArgs           = lambda.Parameters.Zip(expression.Arguments, (p, a) => Tuple.Create(p, a));
                var paramDefineToPopers = from pair in paramArgs
                                          select CodeContext.Add(pair.Item1.Name, pair.Item2);

                var allParamDefineToPopers = paramDefineToPopers.ToArray();

                ///
                /// Do the work. We parse the body of the lambda expression. The references to the parameters should be automatically
                /// dealt with.
                ///

                var result = lambda.Body.Resolve(GeneratedCode, CodeContext, MEFContainer);

                ///
                /// Now, pop everything off!
                ///

                foreach (var param in allParamDefineToPopers)
                {
                    param.Pop();
                }

                ///
                /// Done!
                ///

                return(result);
            }
Ejemplo n.º 14
0
 internal override Expression VisitInvocation(InvocationExpression iv)
 {
     if (CommonUtil.IsClientType(iv.Expression.Type) || iv.Arguments.Any((Expression a) => CommonUtil.IsClientType(a.Type)))
     {
         throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Constructing or initializing instances of the type {0} with the expression {1} is not supported.", type, iv.ToString()));
     }
     return(base.VisitInvocation(iv));
 }
Ejemplo n.º 15
0
 internal override Expression VisitInvocation(InvocationExpression iv)
 {
     throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Initializing instances of the entity type {0} with the expression {1} is not supported.", type, iv.ToString()));
 }