Ejemplo n.º 1
0
        void GetFullName_recursed(StringBuilder sb, Type t, bool recursed)
        {
            if (t.IsGenericParameter)
            {
                sb.Append(t.Name);
                return;
            }

            if (t.DeclaringType != null)
            {
                GetFullName_recursed(sb, t.DeclaringType, true);
                sb.Append(".");
            }

            if (!recursed)
            {
                string ns;
                ns = t.GetNamespace();
                if ((ns != null) && (ns != ""))
                {
                    sb.Append(ns);
                    sb.Append(".");
                }
            }

            GetTypeName(sb, t);
        }
Ejemplo n.º 2
0
	void GetFullName_recursed (StringBuilder sb, Type t, bool recursed)
	{
		if (t.IsGenericParameter) {
			sb.Append (t.Name);
			return;
		}

		if (t.DeclaringType != null) {
			GetFullName_recursed (sb, t.DeclaringType, true);
			sb.Append (".");
		}

		if (!recursed) {
			string ns;
			ns = t.GetNamespace ();
			if ((ns != null) && (ns != "")) {
				sb.Append (ns);
				sb.Append (".");
			}
		}

		GetTypeName (sb, t);
	}
Ejemplo n.º 3
0
        // TODO: fine tune this so that our output is less verbose. We need to figure
        // out a way to do this while not making things confusing.
        string FormatType(Type t)
        {
            if (t == null)
            {
                return("");
            }

            string type = GetFullName(t);

            if (type == null)
            {
                return(t.ToString());
            }

            if (!type.StartsWith("System."))
            {
                if (type.IndexOf(".") == -1)
                {
                    return(type);
                }
                if (t.GetNamespace() == this.t.GetNamespace())
                {
                    return(t.Name);
                }
                return(type);
            }

            if (t.HasElementType)
            {
                Type et = t.GetElementType();
                if (t.IsArray)
                {
                    return(FormatType(et) + " []");
                }
                if (t.IsPointer)
                {
                    return(FormatType(et) + " *");
                }
                if (t.IsByRef)
                {
                    return("ref " + FormatType(et));
                }
            }

            switch (type)
            {
            case "System.Byte": return("byte");

            case "System.SByte": return("sbyte");

            case "System.Int16": return("short");

            case "System.Int32": return("int");

            case "System.Int64": return("long");

            case "System.UInt16": return("ushort");

            case "System.UInt32": return("uint");

            case "System.UInt64": return("ulong");

            case "System.Single":  return("float");

            case "System.Double":  return("double");

            case "System.Decimal": return("decimal");

            case "System.Boolean": return("bool");

            case "System.Char":    return("char");

            case "System.String":  return("string");

            case "System.Object":  return("object");

            case "System.Void":  return("void");
            }

            if (type.LastIndexOf(".") == 6)
            {
                return(type.Substring(7));
            }

            //
            // If the namespace of the type is the namespace of what
            // we are printing (or is a member of one if its children
            // don't print it. This basically means that in C# we would
            // automatically get the namespace imported by virtue of the
            // namespace {} block.
            //
            if (this.t.Namespace != null && (this.t.Namespace.StartsWith(t.Namespace + ".") || t.Namespace == this.t.Namespace))
            {
                return(type.Substring(t.Namespace.Length + 1));
            }

            return(type);
        }
Ejemplo n.º 4
0
	// TODO: fine tune this so that our output is less verbose. We need to figure
	// out a way to do this while not making things confusing.
	string FormatType (Type t)
	{
		if (t == null)
			return "";

		string type = GetFullName (t);
		if (type == null)
			return t.ToString ();
		
		if (!type.StartsWith ("System.")) {
			if (type.IndexOf (".") == -1)
				return type;
			if (t.GetNamespace () == this.t.GetNamespace ())
				return t.Name;
			return type;
		}
		
		if (t.HasElementType) {
			Type et = t.GetElementType ();
			if (t.IsArray)
				return FormatType (et) + " []";
			if (t.IsPointer)
				return FormatType (et) + " *";
			if (t.IsByRef)
				return "ref " + FormatType (et);
		}
	
		switch (type) {
		case "System.Byte": return "byte";
		case "System.SByte": return "sbyte";
		case "System.Int16": return "short";
		case "System.Int32": return "int";
		case "System.Int64": return "long";
			
		case "System.UInt16": return "ushort";
		case "System.UInt32": return "uint";
		case "System.UInt64": return "ulong";
			
		case "System.Single":  return "float";
		case "System.Double":  return "double";
		case "System.Decimal": return "decimal";
		case "System.Boolean": return "bool";
		case "System.Char":    return "char";
		case "System.String":  return "string";
			
		case "System.Object":  return "object";
		case "System.Void":  return "void";
		}
	
		if (type.LastIndexOf(".") == 6)
			return type.Substring(7);

		//
		// If the namespace of the type is the namespace of what
		// we are printing (or is a member of one if its children
		// don't print it. This basically means that in C# we would
		// automatically get the namespace imported by virtue of the
		// namespace {} block.
		//	
		if (this.t.Namespace.StartsWith (t.Namespace + ".") || t.Namespace == this.t.Namespace)
			return type.Substring (t.Namespace.Length + 1);
	
		return type;
	}