/// <summary>
        /// Initializes a new instance of the TsSystemType with the specific CLR type.
        /// </summary>
        /// <param name="type">The CLR type represented by this instance of the TsSystemType.</param>
        public TsSystemType(Type type)
            : base(type)
        {
            switch (this.Type.Name)
            {
            case "Boolean": this.Kind = SystemTypeKind.Bool; break;

            case "String":
            case "Char":
                this.Kind = SystemTypeKind.String; break;

            case "Byte":
            case "SByte":
            case "Int16":
            case "Int32":
            case "Int64":
            case "UInt16":
            case "UInt32":
            case "UInt64":
            case "Single":
            case "Double":
            case "Decimal":
            case "IntPtr":
            case "UIntPtr":
                this.Kind = SystemTypeKind.Number; break;

            case "DateTime":
            case "DateTimeOffset":
                this.Kind = SystemTypeKind.Date; break;

            default:
                throw new ArgumentException(string.Format("The type '{0}' is not supported system type.", type.FullName));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Converts SystemTypeKind to the string, that can be used as system type identifier in TypeScript.
        /// </summary>
        /// <param name="type">The value to convert</param>
        /// <returns>system type identifier for TypeScript</returns>
        public static string ToTypeScriptString(this SystemTypeKind type)
        {
            switch (type)
            {
            case SystemTypeKind.Date: return("Date");

            case SystemTypeKind.Bool: return("boolean");
            }

            return(type.ToString().ToLower());
        }