/// <summary> /// Converts a type to its actual declared csharp name. Custom types return the type name. Example 'System.Int32' becomes 'int'. /// </summary> public static string CSharpName(this HUMType.Data.As @as, bool hideSystemObject = false, bool fullName = false, bool highlight = true) { if (highlight == true) { return(@as.HighlightCSharpName(hideSystemObject, fullName)); } if (@as.type == null) { return("null"); } if (@as.type == typeof(int)) { return("int"); } if (@as.type == typeof(string)) { return("string"); } if (@as.type == typeof(float)) { return("float"); } if (@as.type == typeof(void)) { return("void"); } if (@as.type == typeof(double)) { return("double"); } if (@as.type == typeof(bool)) { return("bool"); } if (@as.type == typeof(byte)) { return("byte"); } if (@as.type == typeof(void)) { return("void"); } if (@as.type.IsConstructedGenericType) { return(GenericDeclaration(@as.type)); } if (@as.type == typeof(System.Object) && @as.type.BaseType == null) { return(hideSystemObject ? string.Empty : "object"); } return(fullName ? @as.type.FullName : @as.type.Name); }
private static string HighlightCSharpName(this HUMType.Data.As @as, bool hideSystemObject = false, bool fullName = false) { if (@as.type == null) { return("null".ConstructHighlight()); } if (@as.type == typeof(int)) { return("int".ConstructHighlight()); } if (@as.type == typeof(string)) { return("string".ConstructHighlight()); } if (@as.type == typeof(float)) { return("float".ConstructHighlight()); } if (@as.type == typeof(void)) { return("void".ConstructHighlight()); } if (@as.type == typeof(double)) { return("double".ConstructHighlight()); } if (@as.type == typeof(bool)) { return("bool".ConstructHighlight()); } if (@as.type == typeof(byte)) { return("byte".ConstructHighlight()); } if (@as.type == typeof(void)) { return("void".ConstructHighlight()); } if (@as.type.IsConstructedGenericType) { return(GenericDeclaration(@as.type)); } if (@as.type == typeof(System.Object) && @as.type.BaseType == null) { return(hideSystemObject ? string.Empty : "object".ConstructHighlight()); } return(fullName ? @as.type.FullName.Replace(@as.type.Name, @as.type.Name.TypeHighlight()) : @as.type.Name.TypeHighlight()); }