Ejemplo n.º 1
0
        public StringBuilder Append(StringBuilder builder, bool fullName)
        {
            if (IsAsync)
            {
                builder.Append("async ");
            }

            if (ReturnParameter != null)
            {
                ReturnParameter.Append(builder);
                builder.Append(" ");
            }

            if (DeclaringType != null)
            {
                if (Name == ".ctor")
                {
                    if (string.IsNullOrEmpty(SubMethod) && !IsLambda)
                    {
                        builder.Append("new ");
                    }

                    AppendDeclaringTypeName(builder, fullName);
                }
                else if (Name == ".cctor")
                {
                    builder.Append("static ");
                    AppendDeclaringTypeName(builder, fullName);
                }
                else
                {
                    AppendDeclaringTypeName(builder, fullName)
                    .Append(".")
                    .Append(Name);
                }
            }
            else
            {
                builder.Append(Name);
            }
            builder.Append(GenericArguments);

            builder.Append("(");
            if (MethodBase != null)
            {
                var isFirst = true;
                foreach (var param in Parameters)
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        builder.Append(", ");
                    }
                    param.Append(builder);
                }
            }
            else
            {
                builder.Append("?");
            }
            builder.Append(")");

            if (!string.IsNullOrEmpty(SubMethod) || IsLambda)
            {
                builder.Append("+");
                builder.Append(SubMethod);
                builder.Append("(");
                if (SubMethodBase != null)
                {
                    var isFirst = true;
                    foreach (var param in SubMethodParameters)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            builder.Append(", ");
                        }
                        param.Append(builder);
                    }
                }
                else
                {
                    builder.Append("?");
                }
                builder.Append(")");
                if (IsLambda)
                {
                    builder.Append(" => { }");

                    if (Ordinal.HasValue)
                    {
                        builder.Append(" [");
                        builder.Append(Ordinal);
                        builder.Append("]");
                    }
                }
            }

            if (RecurseCount > 0)
            {
                builder.Append($" x {RecurseCount + 1:0}");
            }

            return(builder);
        }