示例#1
0
        internal static string FormatGenericTypeName(Type type, bool useFullName)
        {
            string typeString = TypeNameFormatter.CreateTypeString(type, useFullName);
            int    length     = typeString.IndexOf('`');

            if (length == -1)
            {
                return(typeString);
            }
            return(typeString.Substring(0, length));
        }
示例#2
0
        private static string CreateGenericTypeString(Type type, bool useFullName, string genericArgumentListStartCharacter, Func <Type, bool, string> genericTypeFormatter, string genericArgumentListEndCharacter)
        {
            StringBuilder stringBuilder = new StringBuilder(TypeNameFormatter.FormatGenericTypeName(type, useFullName) + genericArgumentListStartCharacter);

            Type[] genericArguments = type.GetGenericArguments();
            for (int index = 0; index < genericArguments.Length; ++index)
            {
                stringBuilder.Append(genericTypeFormatter(genericArguments[index], useFullName));
                if (index != genericArguments.Length - 1)
                {
                    stringBuilder.Append(", ");
                }
            }
            stringBuilder.Append(genericArgumentListEndCharacter);
            return(stringBuilder.ToString());
        }
示例#3
0
 public static string FormatTypeForVisualBasic(Type type, bool useFullName)
 {
     if (type == (Type)null)
     {
         return(string.Empty);
     }
     if (TypeNameFormatter.VBPrettyNameLookup.ContainsKey(type))
     {
         return(TypeNameFormatter.VBPrettyNameLookup[type]);
     }
     if (type.IsGenericType)
     {
         return(TypeNameFormatter.CreateGenericTypeString(type, useFullName, "(", TypeNameFormatter.VBGenericArgumentFormatter, ")"));
     }
     return(TypeNameFormatter.CreateTypeString(type, useFullName));
 }
示例#4
0
 public static string FormatTypeForCSharp(Type type, bool useFullName)
 {
     if (type == (Type)null)
     {
         return(string.Empty);
     }
     if (TypeNameFormatter.CSharpPrettyNameLookup.ContainsKey(type))
     {
         return(TypeNameFormatter.CSharpPrettyNameLookup[type]);
     }
     if (type.IsGenericType)
     {
         return(TypeNameFormatter.CreateGenericTypeString(type, useFullName, "<", TypeNameFormatter.CSharpGenericArgumentFormatter, ">"));
     }
     return(TypeNameFormatter.CreateTypeString(type, useFullName));
 }
示例#5
0
 public static string FormatTypeForDefaultLanguage(Type type, bool useFullName)
 {
     return(TypeNameFormatter.FormatTypeForCSharp(type, useFullName));
 }