Beispiel #1
0
        /// <summary>
        /// 各种表达式
        /// </summary>
        /// <param name="expr"></param>
        string ParseObjectCreateExpression(AstNode expr)
        {
            string newtype = "";

            foreach (var v in expr.Children)
            {
                if (v is Comment)
                {
                    Append(v.ToString().Replace("\r\n", ""));
                }
                else if (v is PrimitiveType)
                {
                    newtype = Tools.getPrimitiveTypeName(v.ToString());
                    Append(newtype);
                }
                else if (v is MemberType)
                {
                    newtype = getMemberTypeName(v.ToString());
                    Append(newtype);
                }
                else if (v is SimpleType)
                {
                    newtype = getSimpleTypeName((v as SimpleType).Identifier);
                    Append(newtype);
                }
                else if (v is CSharpTokenNode)
                {
                    if (v.ToString() == "(")//param begin;
                    {
                        Append("(");
                    }
                    else if (v.ToString() == ")")//paramend;
                    {
                        Append(")");
                    }

                    else if (v.ToString() == "new")
                    {
                        Append("new ");
                    }
                    else
                    {
                        Append(v.ToString());
                    }
                }
                else if (v is NewLineNode)
                {
                    AppendLine();
                }
                else if (v is BlockStatement)
                {
                    ParseBlockStatement(v, null);
                }
                else if (v is IdentifierExpression)
                {//add param
                    ParseIdentifierExpression(v as IdentifierExpression, null);
                }


                else
                {
                    logger.LogError("not support ParseObjectCreateExpression element:" + v.GetType().Name + "|" + v.NodeType + "|" + v.StartLocation.Line);
                }

            }
            return newtype;
        }