Pomona.MappedTypeExtensions.GetSchemaTypeName C# (CSharp) Method

GetSchemaTypeName() public static method

public static GetSchemaTypeName ( this mappedType ) : string
mappedType this
return string
        public static string GetSchemaTypeName(this TypeSpec mappedType)
        {
            if (mappedType.IsCollection)
                return "array";

            var dictType = mappedType as DictionaryTypeSpec;
            if (dictType != null && dictType.KeyType == typeof(string))
                return "dictionary";

            if (mappedType.IsNullable)
                return GetSchemaTypeName(mappedType.ElementType);

            var sharedType = mappedType as RuntimeTypeSpec;
            if (sharedType != null)
            {
                var targetType = sharedType.Type;
                if (numberTypes.Contains(targetType))
                {
                    if (targetType == typeof(double) || targetType == typeof(float))
                        return "number";
                    return "integer";
                }

                if (targetType == typeof(string))
                    return "string";

                if (targetType == typeof(bool))
                    return "boolean";

                if (targetType == typeof(decimal))
                    return "decimal";

                if (targetType == typeof(object))
                    return "any";
            }

            return mappedType.Name;
        }
    }