Exemplo n.º 1
0
        private string GetTargetName(bool js)
        {
            var t = CodeName.ToLowerInvariant().TrimEnd('?');

            switch (t)
            {
            case "int16":
            case "int32":
            case "int64":
            case "short":
            case "int":
            case "long":
            case "float":
            case "double":
            case "decimal":
            case "biginteger":
                return(js ? "Number" : "number");

            case "datetime":
            case "datetimeoffset":
            case "system.datetime":
            case "system.datetimeoffset":
                return("Date");

            case "string":
                return(js ? "String" : "string");

            case "bool":
            case "boolean":
                return(js ? "Boolean" : "boolean");
            }

            return(js ? "Object" : GetComplexTypeScriptName());
        }
Exemplo n.º 2
0
        private string GetKVPTypes()
        {
            var    type    = CodeName.ToLowerInvariant().TrimEnd('?');
            var    types   = type.Split('<', '>')[1].Split(',');
            string keyType = GetTargetName(types[0].Trim(), false);

            if (keyType != "string" && keyType != "number")
            { // only string or number are allowed for keys
                keyType = "string";
            }

            string valueType = GetTargetName(types[1].Trim(), false);

            return(string.Format(CultureInfo.CurrentCulture, "{{ [index: {0}]: {1} }}", keyType, valueType));
        }