Mono.CSharp.CSharpCodeGenerator.DetermineTypeOutput C# (CSharp) Method

DetermineTypeOutput() private method

private DetermineTypeOutput ( CodeTypeReference type ) : string
type System.CodeDom.CodeTypeReference
return string
		private string DetermineTypeOutput (CodeTypeReference type)
		{
			string typeOutput = null;
			string baseType = type.BaseType;

			switch (baseType.ToLower (System.Globalization.CultureInfo.InvariantCulture)) {
				case "system.int32":
					typeOutput = "int";
					break;
				case "system.int64":
					typeOutput = "long";
					break;
				case "system.int16":
					typeOutput = "short";
					break;
				case "system.boolean":
					typeOutput = "bool";
					break;
				case "system.char":
					typeOutput = "char";
					break;
				case "system.string":
					typeOutput = "string";
					break;
				case "system.object":
					typeOutput = "object";
					break;
				case "system.void":
					typeOutput = "void";
					break;
#if NET_2_0
				case "system.byte":
					typeOutput = "byte";
					break;
				case "system.sbyte":
					typeOutput = "sbyte";
					break;
				case "system.decimal":
					typeOutput = "decimal";
					break;
				case "system.double":
					typeOutput = "double";
					break;
				case "system.single":
					typeOutput = "float";
					break;
				case "system.uint16":
					typeOutput = "ushort";
					break;
				case "system.uint32":
					typeOutput = "uint";
					break;
				case "system.uint64":
					typeOutput = "ulong";
					break;
#endif
				default:
#if NET_2_0
					StringBuilder sb = new StringBuilder (baseType.Length);
					if (type.Options == CodeTypeReferenceOptions.GlobalReference) {
						sb.Append ("global::");
					}

					int lastProcessedChar = 0;
					for (int i = 0; i < baseType.Length; i++) {
						char currentChar = baseType[i];
						if (currentChar != '+' && currentChar != '.') {
							if (currentChar == '`') {
								sb.Append (CreateEscapedIdentifier (baseType.Substring (
									lastProcessedChar, i - lastProcessedChar)));
								// skip ` character
								i++;
								// determine number of type arguments to output
								int end = i;
								while (end < baseType.Length && Char.IsDigit (baseType [end]))
									end++;
								int typeArgCount = Int32.Parse (baseType.Substring (i, end - i));
								// output type arguments
								OutputTypeArguments (type.TypeArguments, sb, typeArgCount);
								// skip type argument indicator
								i = end;
								// if next character is . or +, then append .
								if ((i < baseType.Length) && ((baseType[i] == '+') || (baseType[i] == '.'))) {
									sb.Append ('.');
									// skip character that we just processed
									i++;
								}
								// save postion of last processed character
								lastProcessedChar = i;
							}
						} else {
							sb.Append (CreateEscapedIdentifier (baseType.Substring (
								lastProcessedChar, i - lastProcessedChar)));
							sb.Append ('.');
							// skip separator
							i++;
							// save postion of last processed character
							lastProcessedChar = i;
						}
					}

					// add characters that have not yet been processed 
					if (lastProcessedChar < baseType.Length) {
						sb.Append (CreateEscapedIdentifier (baseType.Substring (lastProcessedChar)));
					}

					typeOutput = sb.ToString ();
#else
					typeOutput = GetSafeName (baseType);
					typeOutput = typeOutput.Replace ('+', '.');
#endif
					break;
			}
			return typeOutput;
		}
CSharpCodeGenerator