Esempio n. 1
0
        /// <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)
            {
                return(@as.HighlightCSharpName(hideSystemObject, fullName));
            }
            if (@as.type == null)
            {
                return("null");
            }
            if (@as.type == typeof(CSharp.Void))
            {
                return("void");
            }
            if (@as.type.IsConstructedGenericType || @as.type.IsGenericType)
            {
                return(GenericDeclaration(@as.type));
            }
            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 == typeof(object) && @as.type.BaseType == null)
            {
                return(hideSystemObject ? string.Empty : "object");
            }
            if (@as.type == typeof(object[]))
            {
                return("object[]");
            }

            return(fullName ? @as.type.FullName : @as.type.Name);
        }
Esempio n. 2
0
        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(CSharp.Void))
            {
                return("void".ConstructHighlight());
            }
            if (@as.type.IsConstructedGenericType || @as.type.IsGenericType)
            {
                return(GenericDeclaration(@as.type));
            }
            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.IsEnum)
            {
                return(@as.type.Name.EnumHighlight());
            }
            if (@as.type.IsInterface)
            {
                return(@as.type.Name.InterfaceHighlight());
            }
            if (@as.type == typeof(System.Object) && @as.type.BaseType == null)
            {
                return(hideSystemObject ? string.Empty : "object".ConstructHighlight());
            }
            if (@as.type == typeof(object[]))
            {
                return("object".ConstructHighlight() + "[]");
            }

            return(fullName ? @as.type.FullName.Replace(@as.type.Name, @as.type.Name.TypeHighlight()) : @as.type.Name.TypeHighlight());
        }
Esempio n. 3
0
 public static T New <T>(this HUMType.Data.As @as)
 {
     return((T)HUMType.New(@as.type));
 }