Ejemplo n.º 1
0
        private static void AppendType(TypeReference type, StringBuilder name, bool fq_name, bool top_level)
        {
            TypeReference declaringType = type.DeclaringType;

            if (declaringType != null)
            {
                TypeParser.AppendType(declaringType, name, false, top_level);
                name.Append('+');
            }
            string @namespace = type.Namespace;

            if (!string.IsNullOrEmpty(@namespace))
            {
                TypeParser.AppendNamePart(@namespace, name);
                name.Append('.');
            }
            TypeParser.AppendNamePart(type.GetElementType().Name, name);
            if (!fq_name)
            {
                return;
            }
            if (type.IsTypeSpecification())
            {
                TypeParser.AppendTypeSpecification((TypeSpecification)type, name);
            }
            if (TypeParser.RequiresFullyQualifiedName(type, top_level))
            {
                name.Append(", ");
                name.Append(TypeParser.GetScopeFullName(type));
            }
        }
Ejemplo n.º 2
0
        private static void AppendTypeSpecification(TypeSpecification type, StringBuilder name)
        {
            if (type.ElementType.IsTypeSpecification())
            {
                TypeParser.AppendTypeSpecification((TypeSpecification)type.ElementType, name);
            }
            ElementType etype = type.etype;

            switch (etype)
            {
            case ElementType.Ptr:
                name.Append('*');
                return;

            case ElementType.ByRef:
                name.Append('&');
                return;

            case ElementType.ValueType:
            case ElementType.Class:
            case ElementType.Var:
                return;

            case ElementType.Array:
                break;

            case ElementType.GenericInst:
            {
                GenericInstanceType        genericInstanceType = (GenericInstanceType)type;
                Collection <TypeReference> genericArguments    = genericInstanceType.GenericArguments;
                name.Append('[');
                for (int i = 0; i < genericArguments.Count; i++)
                {
                    if (i > 0)
                    {
                        name.Append(',');
                    }
                    TypeReference typeReference = genericArguments[i];
                    bool          flag          = typeReference.Scope != typeReference.Module;
                    if (flag)
                    {
                        name.Append('[');
                    }
                    TypeParser.AppendType(typeReference, name, true, false);
                    if (flag)
                    {
                        name.Append(']');
                    }
                }
                name.Append(']');
                return;
            }

            default:
                if (etype != ElementType.SzArray)
                {
                    return;
                }
                break;
            }
            ArrayType arrayType = (ArrayType)type;

            if (arrayType.IsVector)
            {
                name.Append("[]");
                return;
            }
            name.Append('[');
            for (int j = 1; j < arrayType.Rank; j++)
            {
                name.Append(',');
            }
            name.Append(']');
        }