Beispiel #1
0
        protected string GetArgumentsMap <T>(List <T> arguments, ArgumentMapType argumentMapType)
        {
            string argumentsMap = "";
            char   argumentChar = 'a';

            int expressiondCount = 0;

            foreach (INode argument in arguments)
            {
                if (argumentMapType == ArgumentMapType.Typed)
                {
                    string        argumentType          = "";
                    TypeReference argumentTypeReference = GetExpressionType((Expression)argument);
                    if (argumentTypeReference != null)
                    {
                        argumentType = GetFullName(argumentTypeReference);
                        if (TypeReference.PrimitiveTypesJavaReverse.ContainsKey(argumentType))
                        {
                            argumentType = (string)TypeReference.PrimitiveTypesJavaReverse[argumentType];
                        }
                        if (argumentType == "java.lang.String")
                        {
                            argumentType = "String";
                        }
                    }
                    argumentsMap += argumentType + " " + argumentChar + ",";
                }
                else if (argumentMapType == ArgumentMapType.Untyped)
                {
                    argumentsMap += argumentChar + ",";
                }
                else if (argumentMapType == ArgumentMapType.Expression)
                {
                    if (argument is Expression)
                    {
                        string str = argumentChar.ToString();
                        if (expressiondCount == 0)
                        {
                            str = GetTargetString((Expression)argument);
                            expressiondCount++;
                        }
                        str           = RemoveNamespace(str);
                        argumentsMap += str + ",";
                    }
                }

                argumentChar++;
            }
            if (argumentsMap.EndsWith(","))
            {
                argumentsMap = argumentsMap.Substring(0, argumentsMap.Length - 1);
            }

            return(argumentsMap);
        }
Beispiel #2
0
        protected string CreateMapKey(INode expression, ArgumentMapType typedArguments)
        {
            if (expression is InvocationExpression)
            {
                InvocationExpression ivExpression = (InvocationExpression)expression;
                string methodKey = null;
                if (ivExpression.TargetObject is FieldReferenceExpression)
                {
                    FieldReferenceExpression methodTargetObject = (FieldReferenceExpression)ivExpression.TargetObject;
                    methodKey = methodTargetObject.FieldName;
                }
                else if (ivExpression.TargetObject is IdentifierExpression)
                {
                    methodKey = ((IdentifierExpression)ivExpression.TargetObject).Identifier;
                }

                string argumentsString = GetArgumentsMap(ivExpression.Arguments, typedArguments);
                return(methodKey + "(" + argumentsString + ")");
            }
            else if (expression is FieldReferenceExpression)
            {
                FieldReferenceExpression fieldReference = (FieldReferenceExpression)expression;
                return(fieldReference.FieldName);
            }
            else if (expression is ObjectCreateExpression)
            {
                ObjectCreateExpression objectCreation = (ObjectCreateExpression)expression;
                string objectCreationKey = "new " + objectCreation.CreateType.Type;
                string parametersString  = GetArgumentsMap(objectCreation.Parameters, typedArguments);
                return(objectCreationKey + "(" + parametersString + ")");
            }
            else if (expression is MethodDeclaration)
            {
                MethodDeclaration method = (MethodDeclaration)expression;
                string            methodDeclarationKey = method.Name;
                string            parametersString     = GetArgumentsMap(method.Parameters, typedArguments);
                return(methodDeclarationKey + "(" + parametersString + ")");
            }
            return(null);
        }